Like模糊查询:
SELECT
*
FROM
table
WHERE username NOT LIKE '%测试%'
AND username NOT LIKE '%ceshi%'
AND username NOT LIKE '%tester%'
;
正则匹配:
SELECT
*
FROM
table
WHERE username NOT REGEXP '测试|ceshi|tester'
;
SQL模糊查询与正则匹配
本文介绍如何在SQL中使用Like进行模糊查询以及使用正则表达式进行精确模式匹配。通过具体的SQL语句示例,展示了排除特定关键词的查询方法。
Like模糊查询:
SELECT
*
FROM
table
WHERE username NOT LIKE '%测试%'
AND username NOT LIKE '%ceshi%'
AND username NOT LIKE '%tester%'
;
正则匹配:
SELECT
*
FROM
table
WHERE username NOT REGEXP '测试|ceshi|tester'
;
1961

被折叠的 条评论
为什么被折叠?