工作小总结

mysql 字段包含某个字符的函数

通过sql查询语句,查询某个字段中包含特定字符串:例子:查询e_book表的types字段包含字符串"3",有下面4种方式select * from e_book where types like "%3%";select * from e_boo

 通过sql查询语句,查询某个字段中包含特定字符串:

例子:查询e_book表的types字段包含字符串"3",有下面4种方式

select * from e_book where types like "%3%";

select * from e_book where find_in_set('3', types);

select * from e_book where locate('3', types);


select * from e_book where INSTR(types,'3');

第2、3中方式相对速度较快

如果使用find_in_set不行的话,可以换成locate.

使用案例:

98a49bc8402555846c0170606776462a.png

select * from (
        select
                cb.id, cb.code, cb.contract_type contractType, cb.target,b.real_name targetName,
                cb.start_date startDate, cb.end_date endDate, cb.real_end_date realEndDate, cb.finance_group_id financeGroupId,
                cb.dep

原创不易,完成人机校验,阅读全文

相关推荐