Select t1.*, t2.Name ,(Select Count(*) from table2 where ID >100) h2
  from table1 t1, (Select * from table2 where ID >100) as t2
  where t1.ID=t2.ID

解决方案 »

  1.   

    Select Count(*) from t12时,提示t2找不到是不是这句话的t12写错了,应该是t2阿
      

  2.   

    Select t1.*, t2.Name 
    ,(Select Count(*) from table2 where id>100) h2  --这里不能直接引用t2,因为它不是一个表
    from table1 t1, (Select * from table2 where ID >100) as t2
    where t1.ID=t2.ID
      

  3.   

    引用字段可以,是因为字段是从from后的表集中提取的.而引用表时,它是从数据库中找的,而不是从from语句中.
    这两个的性质不同.
      

  4.   

    t12不存在,更改一下就行了,當然要滿足需求。
    Select t1.*, t2.Name ,(Select Count(*) from t1) h2
      from table1 t1, (Select * from table2 where ID >100) as t2
      where t1.ID=t2.ID

    Select t1.*, t2.Name ,(Select Count(*) from t2) h2
      from table1 t1, (Select * from table2 where ID >100) as t2
      where t1.ID=t2.ID