字母跟数字是分别2个字段吗? 如果是的话。select * from tablename t where t.数字=1 and t.数字=3
假设 你的2个字段的名字分别是A 与 B select * from table where B=1 or B=3
select * from tablename t where t.数字=1 只包含1 select * from tablename t where t.数字 in(1,3) 1和3
lz的意思是 以a分组 b组只能出现1或者1和3?假设表名tb1,2列为col1,col2select * from (select col1,wm_concat(col2) col2 from tb1 group by col2) where col2 in ('1','1,3')
如果wm_concat得到的是('3,1')呢!不是漏掉了许多记录。
嗯 貌似有可能 那改成where col2 in ('1','1,3','3,1')应该可以了
兄弟,看一下!下面sql是否满足你的需求: with t2 as( select 'a' a,1 b from dual union select 'a',2 from dual union select 'a',3 from dual union select 'b',1 from dual union select 'b',2 from dual union select 'c',1 from dual union select 'c',3 from dual ) select * from t2 t where (t.b=1 or t.b in(1,3));
如果是的话。select * from tablename t where t.数字=1 and t.数字=3
假设 你的2个字段的名字分别是A 与 B
select * from table where B=1 or B=3
select * from tablename t where t.数字 in(1,3) 1和3
(select col1,wm_concat(col2) col2
from tb1
group by col2)
where col2 in ('1','1,3')
嗯 貌似有可能 那改成where col2 in ('1','1,3','3,1')应该可以了
select 'a' a,1 b from dual
union
select 'a',2 from dual
union
select 'a',3 from dual
union
select 'b',1 from dual
union
select 'b',2 from dual
union
select 'c',1 from dual
union
select 'c',3 from dual
)
select * from t2 t where (t.b=1 or t.b in(1,3));