Re: [PHP] Re: SQL Queries

2009-12-20 Thread Jonathan Tapicer
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

[PHP] Re: SQL Queries

2009-12-20 Thread דניאל דנון
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