Вопрос

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

Это было полезно?

Решение

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

Code:

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

Другие советы

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';
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top