select item1 as myitem from tb1 where myitem='1000'
where后面为什么不能使用myitem呢,有没有解决办法

解决方案 »

  1.   

    select item1 as myitem from tb1 where myitem='1000'
    myitem是表名?
      

  2.   

    select item1 as myitem from tb1 where item1 ='1000' 
      

  3.   

    select * from (select item1 as myitem from tb1) where myitem='1000'
      

  4.   

    select item1 as myitem from tb1 where item1 ='1000' 
      

  5.   

    select item1 as myitem from tb1 where item1 ='1000' 
      

  6.   

    SELECT * FROM (select item1 as myitem from tb1 where myitem ='1000' )AS T WHERE 
    myitem ='1000'
      

  7.   

    貌似只有order by 可以 as 后面那个
    其他的 where group by都不行
      

  8.   

    select * from (select item1 as myitem from tb1) where myitem='1000'
      

  9.   

    create table AB(AB varchar(30))
    go
    insert into AB
    values('123')
    go
    insert into AB
    values('456')
    go
    select * from AB where AB = '123'
    go
    drop table AB
    在SQL Server2008中测试通过,可以查出结果
      

  10.   

    嵌套一层才能用到,主要是SQL解析顺序的不同.
      

  11.   

    select item1 as myitem from tb1 
    where item1 ='1000' 
    group by  item1 
    order by  myitem  --或者item1 
      

  12.   

    --查询的逻辑执行过程,来自技术内幕 
    (8)  SELECT (9) DISTINCT (11) <TOP_specification> <select_list> 
    (1)  FROM <left_table> 
    (3)    <join_type> JOIN <right_table> 
    (2)      ON <join_condition> 
    (4)  WHERE <where_condition> 
    (5)  GROUP BY <group_by_list> 
    (6)  WITH {CUBE | ROLLUP} 
    (7)  HAVING <having_condition> 
    (10) ORDER BY <order_by_list> --你看啊,select 清单到第11步才计算,你在第4步又怎么能用得到呢?