java - mysql的查询正则表达式怎么写?
PHP中文网
PHP中文网 2017-04-18 10:56:41
0
4
550

mysql现在有一个字段code,我现在需要的规则是,前一位(或两位)我提供了固定值,java后台生成的,比如I或IC。然后后四位随意,然后后两位后面的4位java后台也会生成,也是固定的,最后末尾还有三位随意。比如I17 04 0000 000或IC17 04 0000 000

难么mysql的select语句怎么写,求大神告知。。。。
PS.1位(两位)固定,四位随意,四位固定,三位随意
select code from xxxx where??

PHP中文网
PHP中文网

认证0级讲师

reply all(4)
大家讲道理
SELECT code FROM xxxx WHERE code REGEXP '^(I|IC)[0-9]{4}0000[0-9]{3}$';

or

SELECT code FROM xxxx WHERE code LIKE 'I____0000%' OR code LIKE 'IC____0000___';
左手右手慢动作

where code REGEXP is followed by a regular expression

阿神

In addition to using like, can other methods be used for fuzzy search in MySQL?

迷茫

Use like, mysql does not have regular expressions, so there is no need to use regular expressions for your needs.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!