我有一个WHERE子句,其中我只想返回field1包含"F"的记录,但它 Select 了任何包含"F"的值,"_"没有被查看吗?
例. 字段1 JBHi-Fi JBHiFi_F_1234
select * from table1
where field1 like "%_F_%"
我有一个WHERE子句,其中我只想返回field1包含"F"的记录,但它 Select 了任何包含"F"的值,"_"没有被查看吗?
例. 字段1 JBHi-Fi JBHiFi_F_1234
select * from table1
where field1 like "%_F_%"
_
is considered as wild card like %
and it means search for 1 character. So, your query is as good as '%F%'
. If you want to search for a pattern like %_F_%'
then you need to use this \ as escape character.
Use
where field1 like "%\_F\_%"