Hi all,
I'm having real trouble with a DELETE operation. I can usually sort out my SQL woes one way or another but this one has me stumped.
I wish to delete rows in a table 'shortlist' where shortlists.username does not exist in users.username. (Background: I want to clean-out guest user shortlists (shopping cart type thing) who don't have a registered account).
The nearest I can get is this:
DELETE FROM shortlists USING shortlists,users WHERE shortlists.username = users.username;
which does the opposite of what i want, as expected. It leaves the rows which don't have a match for 'username' in table 'users'
I've tried changing the '=' operator to <> and != but then it just deletes everything!
I've tried as many of the documented examples as possible, but none do what they claim (most just give syntax errors, which I don't understand). I'm using 4.0.13.
Any help very gratefully received!
Thanks in advance
simonk