【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);