表A
id book_title
-----------------
1 Harry,Potter
2 Limitless案例1:
select * from A where book_title like '%Harry%'
Output:
1 Harry,Potter它起作用了
但在案例2中:
select * from A where book_title like '%HarryPotter%'
Output:
<Nothing>当然,因为这个参数必须与HarryPotter匹配。
是否有任何sql语句可以以如下方式显示输出:
Parameter: HarryPotter
SQL: ?
Output: 1 Harry,Potter谢谢。
发布于 2015-11-18 10:04:55
在执行LIKE时,首先使用REPLACE从book_title中删除任何,:
select * from A where replace(book_title,',','') like '%HarryPortter%'发布于 2015-11-18 10:03:37
只要在where语句中插入逗号,或者使用%(如果您不确定,这两个单词之间是什么):
select * from A where book_title like '%Harry%Portter%'发布于 2015-11-18 10:04:31
在这种情况下,您需要设置函数,尝试如下所示
SELECT ... WHERE FIND_IN_SET('Harry', field)https://stackoverflow.com/questions/33776916
复制相似问题