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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Concat columns from 2 tables
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jchoudja
Starting Member

USA
41 Posts

Posted - 03/22/2013 :  10:32:16  Show Profile  Reply with Quote
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


Edited by - jchoudja on 03/22/2013 10:44:21

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 03/22/2013 :  11:12:24  Show Profile  Reply with Quote
SELECT ID, Name, DateIn, TimeIn FROM Table1
UNION ALL
SELECT ID, Name, DateIn, TimeIn From Table2
ORDER BY ID, DateIn,TimeIn;
Go to Top of Page

jchoudja
Starting Member

USA
41 Posts

Posted - 03/25/2013 :  10:39:30  Show Profile  Reply with Quote
Thank you

jc
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000