mysql现在有一个字段code,我现在需要的规则是,前一位(或两位)我提供了固定值,java后台生成的,比如I或IC。然后后四位随意,然后后两位后面的4位java后台也会生成,也是固定的,最后末尾还有三位随意。比如I17 04 0000 000或IC17 04 0000 000难么mysql的select语句怎么写,求大神告知。。。。PS.1位(两位)固定,四位随意,四位固定,三位随意select code from xxxx where??
认证0级讲师
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.
or
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.