相关子查询,ZZFNO其实是引用了外部查询表T_ZMFC的ZZFNO字段

解决方案 »

  1.   


    declare @t1 table(a int,b int)
    insert into @t1
    select 1,2
    declare @t2 table(b int)
    /*
    --select a from @t1 where a=1 and a in(select c from @t2)
    服务器: 消息 207,级别 16,状态 3,行 7
    列名 'c' 无效。
    */
    /*
    select a from @t1 where a=1 and a in(select a from @t2)
    @t2无记录时,没有查询结果。*/
    /*
    insert into @t2
    select 3
    select a from @t1 where a=1 and a in(select a from @t2)a
    ---
    1
    */--综上,a in(select a from @t2)中的select a from @t2相当于select a from @t2,@t1
      

  2.   

    use northwind
    go
    select top 1 *
    from orders as t1
    where exists(
    select customerid
    from [order details] as t2
    )