请考虑以下信息:
id message
------------------------------------------------------------
1 $AA is the only way to go!
2 This is my $AA. There are many like it.
3 But this is my $AA.
4 My$AA is my swag.
5 For lack of imagination a message with $AA in the middle.
6 Another message with at the end: $AA
我想用$ AA过滤所有邮件:
我通常会使用诸如
之类的查询SELECT * FROM messages WHERE message LIKE '%$AA%'
但是也返回了消息4。如何使查询不返回消息4?
答案 0 :(得分:1)
在您的查询中添加空格太简单了 -
SELECT * FROM table_name WHERE messages LIKE '% $AA%'
这不会涵盖
的第一行使用它:
SELECT * FROM table_name WHERE messages LIKE '% $AA%' or messages like '$AA%'