Hello,
That kind of queries usually run faster using a LEFT JOIN, like this:
select u.id
from users u
left join notes n on u.id = n.user_id
where n.id is null;
That query will give you the ids of the users without notes. Make sure
to have an index on notes.user_id to let the LEFT JOIN use i
Sorry for the double-post, forgot to add up the way I thought about using:
Simple sql query:
SELECT * FROM `users` as u WHERE (SELECT COUNT(id) FROM notes WHERE user_id
= u.id LIMIT 0,1) = 0
Problem is I have about 450,000 "users" and about 90% don't have "notes",
and it takes LOADS of times ev
2 matches
Mail list logo