* Kim Cosgrove > This should be an easy sql question for someone. I've got 2 tables that > have a linked field (id) and I need to clean up records that are > in table1, > but no matching id in table2. This is how I can select them > > SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id WHERE > table2.id IS NULL > > Now the problem. I want to delete them, and I haven't been able to figure > that one out. This is what I tried: > > DELETE table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id WHERE > table2.id IS NULL > > I also tried: > > DELETE FROM table1 LEFT JOIN table2 ON table1.id=table2.id WHERE table2.id > IS NULL > > I got syntax errors on both. Can anyone tell me how to delete these > unmatched records?
There is an example of this in the manual: <URL: http://www.mysql.com/doc/A/N/ANSI_diff_Sub-selects.html > -- Roger --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php