日期:2014-05-17  浏览次数:20824 次

oracel (列,列) in (值1,值2)的用法
由于有一个excle数据拼接成一个sql语句


SQL code
select  s_landedcost,s_styleno,s_seasonyear,s_seasoncode 
from t_style 
where (s_styleno,s_seasonyear,s_seasoncode) in
 ('NH199','2005','N'
,'NH199','2005','N' );


不知道可以否?

------解决方案--------------------
不能这么用.假设
'NH199','2005','N'
'NH199','2005','N'
是某个表t的三个列,c1 , c2 , c3

select m.s_landedcost,m.s_styleno,m.s_seasonyear,m.s_seasoncode 
from t_style m
where exists (select 1 from t where m.s_styleno = t.c1 and m.s_seasonyear = t.c2 and m.s_seasoncode = t.c3)

select m.s_landedcost,m.s_styleno,m.s_seasonyear,m.s_seasoncode 
from t_style m,t
where m.s_styleno = t.c1 and m.s_seasonyear = t.c2 and m.s_seasoncode = t.c3





------解决方案--------------------
select s_landedcost,s_styleno,s_seasonyear,s_seasoncode 
from t_style 
where (s_styleno,s_seasonyear,s_seasoncode) in
(
select 'NH199','2005','N' from dual
union all
select 'NH199','2005','N' from dual
)tb;
------解决方案--------------------
SQL code

--可以这样
select s_landedcost, s_styleno, s_seasonyear, s_seasoncode
  from t_style
 where (s_styleno, s_seasonyear, s_seasoncode) in
       (('NH199', '2005', 'N'),( 'NH199', '2005', 'N'));