1.包含FIND_IN_SET
select gid, username from users where FIND_IN_SET(8,gid); //查询gid里含有数字8的记录,gid是varchar ,数据格式:"1,12,8,18,5"
2.第一种 不包含 !FIND_IN_SET
select gid, username from users where !FIND_IN_SET(8,gid); //查询gid里不含有数字8的记录,gid是varchar ,数据格式:"1,12,8,18,5"
3.第二种 not in
SELECT *
from sys_dept d
where d.dept_id NOT IN (11667
) and d.tag=6
4.第三种 count()
select * from sys_dept d where (select count(1) as num from gt_allocation_unit a where a.org_id=d.dept_id) = 0;