如何写一条语句能满足以下条件
1.列mta里含有","号,而且在一个值里出现指定次数的。
SELECT * from test where id not IN(
select id from test WHERE name LIKE '%,%,%')
如果是ORACLE
select * from 表 b where instr(b.mta,',',1,1)>0 and instr(b.mta,',',1,2)=0
SELECT * from test where name not LIKE '%,%,%,%,%' #出现四次以下的
and id not IN
(select id from test where name not like '%,%,%,%') #出现三次以下的
#做差 就是出现三次的
Mysql
select * from 表 b
where LOCATE(',', b.mta)>0 and LOCATE(',', b.mta,select LOCATE(',', b.mta) from 表 c)=0
select * from 表 b where instr(b.mta,',',1,2)>0 and instr(b.mta,',',1,3)=0 出现2次的
select * from 表 b where instr(b.mta,',',1,3)>0 and instr(b.mta,',',1,4)=0 出现3次的
select * from 表 b where instr(b.mta,',',1,4)>0 and instr(b.mta,',',1,5)=0 出现4此的
。。。。