1.使用函数instr
instr(',' || PRINCIPAL || ',', ',' || #{principal} || ',')>0
数据库中的字段为
使用该方式后相当于像前后各拼接了一个逗号
instr(',' || '24,43' || ',', ',' || '43' || ',')>0
2.使用函数FIND_IN_SET(str,strlist)(字段值只能以逗号分隔)
SELECT FIND_IN_SET("c", "a,b,c,d,e");
使用这个方法sql语句可以变成如下:
select name,project from ic_customer where FIND_IN_SET('24',PRINCIPAL)
上面的where语句和FIND_IN_SET('1',brand_management) > 0 是相等的,只是默认查询的是索引 > 0的结果。