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 even with I limit it: SELECT * FROM `users` as u WHERE (SELECT COUNT(id) FROM notes WHERE user_id = u.id LIMIT 0,1) = 0 LIMIT 0,10 Takes about 10 seconds which is too much time... Any way to optimize it? On Sun, Dec 20, 2009 at 11:30 PM, דניאל דנון <danondaniel@xxxxxxxxx> wrote: > Hey, Lets assume I got a table named "users". > It contains id & name. > > I have another table called "notes" - which contains id, user_id, contents > > > I want to delete all users from table "users" that don't have notes (SELECT > ... FROM notes WHERE user_id=ID) returns empty result. > > > What is the fastest way to do it? > > -- > Use ROT26 for best security > -- Use ROT26 for best security