有个需求是要查询字段中code前缀是H、M、81、82开头的
方法一 使用like和or
select * from zhy where code like 'H%' or code like 'M%' or code like '81%' or code like '82%';
方法二 使用正则表达式
select * from zhy where code REGEXP '^H|^M|^81|^82';
方法三 使用in
select * from zhy where left(code,2) IN ( 81,82 ) or left(code,1) IN ( 'H','M' );
方法四 使用FIND_IN_SET
select * from zhy where FIND_IN_SET(left(code,2),"81,82") or FIND_IN_SET(left(code,1),"H,M");