1

我正在尝试搜索这种模式 ab1234。我试过col like 'ab[0-9][0-9][0-9][0-9]' col like '(ab)[0-9]{4}' col like 'ab####' 这些都不起作用。我检查了这个网站https://www.w3schools.com/sql/sql_wildcards.asp,但它不是很有帮助。任何建议表示赞赏:)

4

2 回答 2

1
select * from table where col rlike 'ab[0-9]{4}'
于 2021-02-08T04:57:08.117 回答
1

使用 rlike 进行正则表达式检查:

col rlike 'ab\\d{4}' --containing ab and 4 digits in any place of the string

或更严格的模式:

col rlike '^ab\\d{4}$' --Exactly ab and 4 digits, no other characters before or after
于 2021-02-07T10:08:22.270 回答