Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Concat columns from 2 tables

Author  Topic 

jchoudja
Starting Member

41 Posts

Posted - 2013-03-22 : 10:32:16
Hi, Hi have tables I will like to combine in 1 table.

Table 1
HomeAttendances
ID__|__ Name___|DateIn___|TimeIn
1___|__ John___|03/10/03_|10:10AM
2___|__ Ashley_|03/10/03_|09:15AM
3___|__ Nina___|03/11/03_|03:10PM
4___|__ lisa___|03/15/03_|02:15PM


Table 2
ExternalAttendances
ID__|__Name____|DateIn___|TimeIn
1___|__John____|03/15/03_|07:10PM
5___|__Bill____|03/20/03_|05:25PM
6___|__Joe_____|03/18/03_|03:20PM
7___|__Passi___|03/15/03_|01:10PM


From those 2 tables, I wan to get this:


TotalAttendances
ID__|__Name___|_DateIn___|TimeIn
1___|__John___|_03/10/03_|10:10AM
1___|__John___|_03/15/03_|07:10PM
2___|__Ashley_|_03/10/03_|09:15AM
3___|__Nina___|_03/11/03_|03:10PM
4___|__Lisa___|_03/15/03_|02:15PM
5___|__Bill___|_03/20/03_|05:25PM
6___|__Joe____|_03/18/03_|03:20PM
7___|__Passi__|_03/15/03_|01:10PM

Thank you

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-22 : 11:12:24
[code]SELECT ID, Name, DateIn, TimeIn FROM Table1
UNION ALL
SELECT ID, Name, DateIn, TimeIn From Table2
ORDER BY ID, DateIn,TimeIn;[/code]
Go to Top of Page

jchoudja
Starting Member

41 Posts

Posted - 2013-03-25 : 10:39:30
Thank you

jc
Go to Top of Page
   

- Advertisement -