var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Selecting a Column From Multiple Tables
Is it possible to get a list of rows from Multiple tables which have the same Column Name. I have 3 tables which comtain similar info
and I want to get a list of Names
the structure is
I was thinking something along the lines of SELECT Name FROM TABLE1,TABLE2, TABLE3
But this does not work.
Is there a nice way of doing this with SQL or should I do code outside the SQL DB
Re: Selecting a Column From Multiple Tables
SELECT Table1.Name, Table2.name
FROM TABLE1,TABLE2, TABLE3
I think you want
SELECT 'Table1' AS Source, ID, Name, Address, [Phone No]
SELECT 'Table2' AS Source, ID, Name, Address, [Phone No]
SELECT 'Table3' AS Source, ID, Name, Address, [Phone No]
Happy Hunting (and pecking)
Nice one Brett,
Thats what I needed.. My wording in the question wasn't great. I wanted to get a result with no duplicates and just a list of each ID's and I am using multiple tables. So Now I use a statement :
SELECT ID FROM BDname.dbo.Table1
SELECT ID FROM BDname.dbo.Table2
SELECT ID FROM BDname.dbo.Table3
and it works wonderfully.
Thanks for the help.
P.s. Can any one recommend and good TSQL programming resources ?
Sure...How about this site
Or this Site
Or a good book or 2 on a cold dark rainy night (Ahhh the life of a dba)
BUT...there is NO better method than opening up (and leaving open) QA, BOL and EM and testing things out yourself.....