由于有一个excle数据拼接成一个sql语句如
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' );不知道可以否?

解决方案 »

  1.   

    不能这么用.假设
    'NH199','2005','N'
    'NH199','2005','N'
    是某个表t的三个列,c1 , c2 , c3select 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
      

  2.   

    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;
      

  3.   


    不可以这样写的,这样写oracle会报错
    下面这样可以select *
      from emp
     where (job, deptno) in (SELECT JOB, DEPTNO FROM EMP WHERE DEPTNO = 20)
    EMPNO ENAME      JOB         MGR HIREDATE          SAL      COMM DEPTNO FLAG
    ----- ---------- --------- ----- ----------- --------- --------- ------ ----
     7876 ADAMS      CLERK      7788 1987-5-23     1100.00               20 
     7369 SMITH1     CLERK      7912 1980-12-17     800.00               20 
     7566 JONES      MANAGER    7839 1981-4-2      2975.00               20 
     7902 FORD       ANALYST    7566 1981-12-3     3000.00               20 
     7788 SCOTT      ANALYST    7566 1987-4-19     3000.00               20 
      

  4.   


    --可以这样
    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'));