simple question

A

aannyy

Guest
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? Thanks a lot.
 
The short answer: you don't.

The moderately useful answer:
MSQL 3.x doesn't support subqueries of any kind. MySQL 4.1 does have at least some support for subqueries like you're trying to do, but it's still in alpha stage of development. (MySQL 4.0.x is the latest production version, but the current H-Sphere version doesn't support it, which is why 3.x is still being used).

Anyway, if you need subqueries - and it looks like you do - you could use Postgres or MS SQL instead, both of which are also supplied by JodoHost.
 
aannyy said:
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? Thanks a lot.

You do that using something like this:

SELECT T1.* FROM Table1 T1 LEFT JOIN TABLE2 T2 ON
T1.data1 = T2.data1 WHERE T2.data1 IS NULL

I'll need more information about the exact fields to come up with something suited to your situation
 
Back
Top