SQL Excluding Record sets
I was eating with another speaker at cf.Objective() (I am resolved to find a way to work my having spoken at a conference into all future anecdotes) and an interesting SQL question came up: How to delete everything except the first 1000 records. To my mind, this brought up a general class of problems in SQL. Which is, returning results that exclude the result of a query.
With that in mind, let's look at a few of those.
I'm also a fan of EXISTS for the same reason as you.
I loved the subtle cf.objective reference :)
I'm sorry to hear that MySQL doesn't support EXCEPT. I think it is been in the SQL standard for some time now.
John,
Thanks! Future anecdotes may have to resort to lame "Before I was a speaker at cf.Objective...", but I am not above that! ;-)
I'd go with copying those 1000 to a temp table, and run truncate command on the original table, of course only if you're granted to do that; truncate does not delete row after row, is times more faster;