Menu
Dear users,
I have two tables: “cars” and “users”.
The query is this:
SELECT * FROM cars AS c LEFT JOIN users AS u ON c.uid = u.uid WHERE c.proven = 1 && (u.state = 1 || u.state = NULL)
I want to specify not all the cars have an owner, so c.uid can be 0.
I want to retrieve all the cars not owned (c.uid = 0) and all the cars where the owner has an approved account (u.state = 1).
I tried to add u.state = NULL to get also the cars not owned, because LEFT JOIN returns NULL in all users fields, but this doesn’t work.
How can I fix this issue?
Thanks