-1

I am trying to delete multi rows: I am using this code:

    [db beginTransaction];
       [db executeUpdate:@"delete FROM tasks  WHERE _id NOT LIKE \'temp\%\' andD _id NOT LIKE \'\%prepop\%\' AND _id NOT LIKE \'link\%\'"];
    [db commit];

For some reason the data is not been deleted ...

Rob
  • 415,655
  • 72
  • 787
  • 1,044
Sosily
  • 706
  • 1
  • 10
  • 26
  • 2
    There seems to by at least one typo: `andD`. You *did* copy/paste your real code, didn't you? – Martin R Nov 24 '13 at 12:55
  • You should check the result code of `executeUpdate` and if not `YES`, then log `[db lastErrorMessage]` and that will tell you where the problem is in your SQL. The error is the `andD` typo. As an aside, while it's not an error, all of those backslashes are unnecessary. – Rob Nov 24 '13 at 13:56
  • No i didn't .. but thanks – Sosily Nov 24 '13 at 13:57

1 Answers1

1

Typo:

andD

should be:

AND

However as your statement is illegal you should be getting an error back, so you need to pay more attention to catching and reporting errors.

(Just noticed that @MartinR spotted this immediately so props to him).

trojanfoe
  • 120,358
  • 21
  • 212
  • 242