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

correlated subqueries

Status
Not open for further replies.

eugene1974

Programmer
Mar 15, 2004
1
US
Hi to all.

I'm new to MySQL.

I'm using MySQL 3.23.51

Have a simple question:

How to find a data from one table which is not in another table.

for example I'm writing next statement:

SELECT * FROM table1 WHERE data1 NOT IN (SELECT data1 FROM table2)

when exwcutin it I get error:
"You have an error in your SQL syntax near 'select room_nbr from kc_ip_room)' at line 1"

What is the correct way of doing that in MySQL

Thank's a lot.
Eugene.
 
Eugene

That's an inefficient way of doing what you're trying to do. Now if anybody else had said that, I'd have to say there is no such thing as inefficient SQL any more than there is inefficient English, but in the real world dbmss tend to follow what you're saying when it comes to subselects. You'd be much better joining (which relational dbmss are good at) and selecting on nulls in the joined-to key field.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top