I think this is newbie ask. How to delete row if id doesn't exist in other 开发者_如何学JAVAtable? My thought is fetch the ids first and delete. I'm looking for better querying.
You can set foreign keys to these tables.
More info here
for simple query, here it is:
DELETE FROM table WHERE (SELECT count(1) FROM table2 WHERE id = table.id) < 1
精彩评论