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

one query to tell if a value exists in one of two tables?

Status
Not open for further replies.

lemkepf

Technical User
Oct 8, 2002
86
0
0
US
Hello SQL gods, once again i'm in need of some help.
I have 2 tables. One holds old and discontinued values, one holds new values(the values can't be in both).

I need to write a single select query (more like an existence test) that will return true if the value is in one of the two tables. Can this be done?

Thanks for all your help!
Paul
 
You can use a union query to gather records from 2 or more tables. For example:

select value1 from table1 where value1 = 'condition'
union all
select value1 from table2 where value1 = 'condition'

Then check the record count to see if the value exists.

Hope this helps.

Glen Appleton

VB.Net student.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top