首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

oracel (列,列) in (值1,值2)的用法,该怎么解决

2012-04-08 
oracel (列,列) in (值1,值2)的用法由于有一个excle数据拼接成一个sql语句如SQL codeselects_landedcost,s

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')); 

热点排行