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!

equivalent of Oracle's EXISTS or IN 1

Status
Not open for further replies.

glendacom

MIS
Oct 23, 2002
36
0
0
US
I'm trying to do a query in sql*server that I know how to do in oracle ... can someone tell me the equivalent in sql*server. In Oracle the query would be:

select fieldName1, fieldName2
from Table1
where fieldName1 in (select fieldName1
from Table2)

or

select fieldName1, fieldName2
from Table1
where exists (select 'x'
from Table2
where Table1.fieldName1 = Table2.fieldName2)

My Oracle is very rusty so I'm not absolutely positive of the syntax in the second example but hopefully you get the idea.
 
the first query should work in sql server...not sure why it wouldn't be working for you.
 
sorry, I guess I didn't make myself completely clear. Yes, I know both versions work in SQL*Server but I thought there was a much "cleaner" way to do it in SQL*Server and that was what I was after.

Thanks for the responses.
 
thanks, Terry ... that is exactly what I wanted! A star for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top