954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

select a table but display record from other table

I have 2 table
[EMPLOYEE]
Emp_ID
Emp_Name

[ATTENDANCE]
Emp_ID
Emp_Name
Time_In
Time_Out

How do I display it like this.
I hope I present this right

+--------++----------++---------++---------+
| Emp_ID || Emp_Name || Time_In ||Time_Out | <---- FROM ATTENDANCE
+--------++----------++---------++---------+
|   1    ||   Josh   ||         ||         | <---- FROM EMPLOYEE
+--------++----------++---------++---------+
|   2    ||   Carl   ||         ||         | <---- FROM EMPLOYEE
+--------++----------++---------++---------+
Shizuo
Light Poster
39 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

I really don't understand what the question is.
There are a million possibilities for your result sample:

select employee.emp_id,employee.Emp_Name,attendance.Time_In,attendance.Time_Out
from employee inner join attendance 
on employee.emp_id = attendance.emp_id 
and time_id = ''
and time_out = ''
select attendance.emp_id,attendace.Emp_Name,attendance.Time_In,attendance.Time_Out
from employee left join attendance
on employee.emp_id = attendance.emp_id 
where attendance.emp_id is null
select top 0 * from attendance 
union select emp_id,emp_name,'','' 
from employee


Probably all the above will give a similar result to what you've provided under some conditions. The problem is that you have to specify under what you are trying to do.

adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: