Frage

how can delete "TEST" in message field of posts_comments table

DELETE FROM `posts_comments` WHERE `message` LIKE `TEST`

i want all comments have TEST remove from posts_comments table

War es hilfreich?

Lösung

Just add MySQL Wildcard '%' in order to simulate Contains operation.

Code:

DELETE FROM `posts_comments` WHERE `message` LIKE '%TEST%'

Andere Tipps

You need single quotes (not backticks) around the string constant:

DELETE FROM `posts_comments`
    WHERE `message` LIKE 'TEST';

In fact, queries are easier to read without backticks. Only use backticks when necessary -- when using unusual characters in an identifier (anything except alpha, numeric, or underscore) or MySQL reserved words. Then, follow the rule that you never use unusual characters in an identifier. And never use MySQL reserved words.

DELETE FROM posts_comments
    WHERE message LIKE 'TEST';
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top