【MySQL】SQL LIKE 操作符

一般用法:

包含

SELECT * FROM Persons
WHERE City LIKE '%N%'

开始为

SELECT * FROM Persons
WHERE City LIKE 'N%'

结束为

SELECT * FROM Persons
WHERE City LIKE '%N'

不包含

SELECT * FROM Persons
WHERE City NOT LIKE '%N%'
函数用法

同包含

SELECT * FROM Persons
WHERE City LIKE CONCAT('%', 'N');

这种方式就可以和参数一起使用了

SELECT * FROM Persons
WHERE City LIKE CONCAT('%', CityName);
posted @ 2021-02-22 09:49  养鼠的猫  阅读(111)  评论(0编辑  收藏  举报