Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I combine table with all entries

Status
Not open for further replies.

snoopy80

Technical User
Jun 27, 2001
106
Hello everyone,
This is what I want to do. Let say I have 3 tables each with 2 columns:
Tab 1 Tab 2 Tab 3
Id Name Id Name Id Name
401 John 324 Mary 401 John
511 Peter 511 Peter 522 Jay

I want to combine them into one like this
Id Name
324 Mary
401 John
511 Peter
522 Jay
How can I do that? Thanks for the Help
 
Hi,
Code:
Select *
From Tab1
Union
Select *
From Tab2
Union
Select *
From Tab3


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Thanks for your help Skip. I tried the codes and they actually combine everything. Sorry I did not explain well. The final table should not have duplicate (Id) entries.
Thanks
 
Funny, I get resultset...
[tt]
Id Name
324 Mary
401 John
511 Peter
522 Jay
[/tt]


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
I get the same results as Skip. Are you sure you used the sql statement exactly as he wrote it? Did you leave out some aspect of the tables' structure?

There must be some reason you're getting different results, and if you left something out (for simplification purposes, or whatever), then there's a good chance that the difference is accounted for in that missing information.


Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top