I am trying to combine the two into a single statment, I would even settle for two seperate statements….. I know it must be possible, but how?
this is what I have tried:
DELETE FROM myTable WHERE myValue LIKE 'findme%';
and:
DELETE FROM myTable WHERE EXISTS (SELECT * FROM myTable WHERE myValue LIKE 'findme%');
I get an error for the second statement saying something like, you can only have a single result for a LIKE statement with another statement…
Your first statement should work. Try without the final semicolon maybe?
The second one is not logical. Your subquery is not correlated to the first one and you cannot scan a table which is being modified. Actually what I would expect from this query, if it would ever run, is that all rows are deleted if there is a single row where your column matches…
If you wonder why the solutions with the
INclause work and not theEXISTS, it is because theEXISTScondition is evaluated for each row, whereas theINset is evaluated once.