Solved

Join Tables in SQL

Posted on 2013-01-13
3
238 Views
Last Modified: 2013-01-15
Hello I have the following query which is giving me the data from the people not working on Today.

SELECT *
FROM q2employee_work_schedule
WHERE working = 'N' AND date1 = CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME)

 but is giving me an employee Code "emp_code" which is fine but I need a name, there is another table called dbo.q2employees, how can I join these two tables to get the preferred name "preferred_name"  and surname

Thanks
0
Comment
Question by:jhonc66
  • 2
3 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38773395
SELECT q2employee_work_schedule.* ,q2employees.*
FROM q2employee_work_schedule
Inner join q2employees on q2employee_work_schedule.emp_code =q2employees.emp_code
WHERE working = 'N' AND date1 = CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME)
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 38773396
SELECT q2employee_work_schedule.* ,q2employees.preferred_name,q2employees.surname
FROM q2employee_work_schedule
Inner join q2employees on q2employee_work_schedule.emp_code =q2employees.emp_code
WHERE working = 'N' AND date1 = CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME)
0
 

Author Closing Comment

by:jhonc66
ID: 38780845
Thanks a lot
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question