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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select distinct from multiple tables

Status
Not open for further replies.

simanek

Programmer
Jan 19, 2001
137
US
Is there a way to select distinct entries from a common column across a whole bunch of tables? I have about 100 tables each with a common column and I want to select only the unique entries in that column. Any ideas of how to do this without bringing the database to its knees?

Thanks. Mike
~~~~
simanek@uiuc.edu
"It's a Swingline!"
~~~~
 

You could do a Union query. I'm not sure of the limitation on the number of tables you can include in one UNION query. If there is a limitation, you may need to create more than one query. By default, UNION queries select distinct values.

Select ColA From tbl1
Union
Select ColA From tbl2
Union
Select ColA From tbl3
Union
Select ColA From tbl4
Union
Select ColA From tbl5
Union
.
.
.
Terry Broadbent


"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top