Alessandro95 Alessandro95 - 3 months ago 11
MySQL Question

MySql. DB owner and car

I have 2 tables in my DB:
owner
car

I have to extract the owners that haven't a car and live in IT, we are talking about "Arthur".

SELECT * FROM owner, car WHERE city = 'IT' and owner.idOwner != car.idOwnerFK


city is working but not like the second part.
How can i solve my problem? Thanks

Answer

Try

SELECT  * FROM owner WHERE city = 'IT' and idOwner not in (select  idOwnerFK from car)