有这样一个语句:
select * from table_name where (a = '10' and b = '20') or (a = '30' and b = '8') or (a = '25' and b = '43')...我想用这样的语句来写:
select * from table_name where a in (10, 25, 30) and (20, 8, 43);但是,由于交叉会产生多余的行,有知道的麻烦指点一下。
select * from table_name where (a = '10' and b = '20') or (a = '30' and b = '8') or (a = '25' and b = '43')...我想用这样的语句来写:
select * from table_name where a in (10, 25, 30) and (20, 8, 43);但是,由于交叉会产生多余的行,有知道的麻烦指点一下。
--1.如果是小表的话select * from table_name where a = '10' and b = '20'
union
select * from table_name where a = '30' and b = '8'
union
select * from table_name where a = '25' and b = '43';--2.如果是大表的话
select * from table_name where (a,b) in
(
select '10' a, '20' b from dual
union all
select '30' a, '8' b from dual
union all
select '25' a, '43' b from dual
);