Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一个 SQL 语句,它将只返回我的表中其名称字段包含特殊字符(单引号)的行。
我用了
SELECT * FROM 'table' WHERE Name REGEXP '"$'
我想念什么?
SELECT * FROM 'table' WHERE Name like "%\'%"
SQL小提琴
MySQL 5.5.30 架构设置:
create table test(name varchar(10)); insert into test values('aaa '''' bb'),('bsbds');
查询 1:
select * from test where name regexp "'"
结果:
| NAME | ------------- | aaa '' bb |
仅用于单引号
select * from `table` WHERE Name REGEXP "'";
如果您需要更多特殊符号,例如' % $
' % $
select * from `table` WHERE Name REGEXP "['%$]";