http://qs1969.pair.com?node_id=319119


in reply to deleting from a mysql database

Not really an answer to your question, but you don't need to escape (backslash) the quotation marks inside of a qq(). Also, the backticks around Name are unnecessary in mysql.

The reason that your code doesn't work is that the first time through the loop, you delete everything that is not "Anna". The second time through, you delete everything that is not "Maria" (which is everything in the database). The third time, there is nothing left to delete...

Another monk has already provided code using IN, which should be effective, but slow. It all depends on database sizes...