select * from table2
where
 exists(select * from table1 
  where 
    table1.filed1 = 1 and table2.filed1 = table1.field0 and
    table1.filed1 = 2 and table2.filed2 = table1.field0 and
    table1.filed1 = 3 and table2.filed3 = table1.field0
  )

解决方案 »

  1.   

    三个条件应该是OR关系吧,否则那有table1.field1同时等于 1,2,3的记录啊!
      

  2.   

    关于SQL Server 的阅报和发布,请帮忙。
    http://www.csdn.net/expert/topic/461/461023.shtm 
      

  3.   

    如果我没有理解错你的条件,答案应该不止一条:
    select * from table1 inner join table2 on 
    case 
             when table1.field1=1 then table2.field1
            when table1.field1=2 then table2.field2
             when table1.field1=3 then table2.field3
    end =table1.field0Field0     Field1      Field0     Field1     Field2     Field3     
    ---------- ----------- ---------- ---------- ---------- ---------- 
    a          1           A          a          b          c         
    b          2           A          a          b          c         
    c          3           A          a          b          c         
    d          1           B          d          e          f         (4 row(s) affected)
      

  4.   

    大家请注意我在贴子中写的"AND",是个"与"条件,不是连字符
      

  5.   

    select b.* from table2 b 
    inner join (select b1.* from table2 b1 inner join table1 a1 on a1.field1=1 and a1.field0=b1.field1) c1 on b.field0=c1.field0
    inner join (select b2.* from table2 b2 inner join table1 a2 on a2.field1=2 and a2.field0=b2.field2) c2 on b.field0=c2.field0
    inner join (select b3.* from table2 b3 inner join table1 a3 on a3.field1=3 and a3.field0=b3.field3) c3 on b.field0=c3.field0Field0     Field1     Field2     Field3     
    ---------- ---------- ---------- ---------- 
    A          a          b          c         (1 row(s) affected)
      

  6.   

    to Brunhild():你写的挺有道理,先给你20分,等我把整个语句整合起来,如果好用,再给另外30分