select * from serbillmain a inner join
  ( select * from serBillMain c inner join 
      ( select * from serBillMain where flag = 2 and billno = '20070101' )d 
     on c.phono = d.billno where c.flag = 3) b
on a.comno = b.billno where a.flag = 4
Sqlserver 报错:多次为b指定列Flag.
请问各位如何调整?

解决方案 »

  1.   

    select * from serbillmain a inner join
      ( select * from serBillMain c inner join 
          ( select * from serBillMain where flag = 2 and billno = '20070101' )d 
         on c.phono = d.billno ) b
    on a.comno = b.billno where a.flag = 4 and c.flag = 3
      

  2.   

    参考一下,sql的语法手册,会对你有帮助的
      

  3.   

    select * from serbillmain a inner join
      ( select * from serBillMain c inner join 
          ( select * from serBillMain where flag = 2 and billno = '20070101' )d 
         on c.phono = d.billno ) b
    on a.comno = b.billno where a.flag = 4 and c.flag = 3
    “c.flag = 3”  A,B两表的连接中那里可以限定C的呀!
      

  4.   

    where flag = 2 and billno = '20070101' )d 
    没为FLAG指定表
      

  5.   

    where flag = 2 and billno = '20070101' )d 
    没为FLAG指定表
    能否说祥细一点。
      

  6.   

    好像写的很麻烦
    改成下面试试:
    select a.* from serbillmain a inner join
      ( select c.* from serBillMain c inner join 
          ( select * from serBillMain where flag = 2 and billno = '20070101' )d 
         on c.phono = d.billno where c.flag = 3) b
    on a.comno = b.billno where a.flag = 4