Domanda

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

È stato utile?

Soluzione

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

Code:

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

Altri suggerimenti

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';
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top