get result from a few table with same fields

dec21st

Active member
Joined
May 14, 2005
Messages
43
Programming Experience
3-5
say i have these few fields in these tables

table:Rest
fields
i)id
ii)name
iii)contact
iv)restaurant
v)manager

table:Mgmt
fields
i)id
ii)name
iii)contact
iv)department
v)manager

table:Admin
fields
i)id
ii)name
iii)contact

can i query to get one result showing id,name and contact from all the tables in one result?? the field names are the same. just that the table is diff
 
VB.NET:
SELECT id, name, contact FROM Rest UNION SELECT id, name, contact FROM Mgmt UNION SELECT id, name, contact FROM Admin
This query lets you get all three in one go. You can also Fill a DataTable more than once using several data adapters and the results are cumulative. I believe, although I don't have my copy of SQL in a Nutshell with me to confirm, that you can use UNION in a query even if the field names and count are different.
 
Back
Top