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.
我想选择标题不以 az 或 0-9 字符开头的记录。
一种方法是:
SELECT * FROM table WHERE title NOT LIKE 'a%' AND... title NOT LIKE 'z%' ....
有一个更好的方法吗?
您可以使用正则表达式:
select * from table where title regexp '^[^a-z0-9]'
顺便说一句,第一个^匹配字符串的开头。第二个是[和之间的模式中的字符的否定]。
^
[
]
另一种选择:
SELECT * FROM table WHERE (LEFT(table, 1) NOT BETWEEN 'a' AND 'z') AND (LEFT(table, 1) NOT BETWEEN '0' and '1')