有表store,结构如下name    |     sale   |  sdate 
1             1000        1
2             2000        2
3             2555        3有如下SQL语句,
select name,sale salary from store where salary <= 2000
返回几条数据,为什么?

解决方案 »

  1.   

    我倒,你的表里面可没有salary 字段啊?
      

  2.   

    select name,sale salary from store where salary <= 2000
    汗..不能用别名...select name,sale from store where sale <= 2000得到2条...
      

  3.   

    理论上说 应该是2条如果说 sale  是  varchar 就不确定了 
      

  4.   

    能讲一下为什么不能用别名吗?还有方式可以用别名 ,你的SQL也是一种解决方法
      

  5.   

    应该报错,salary 列名无效
      

  6.   


    --想要别名的话 可以考虑嵌套select * from (select name,sale salary from store)  where salary <= 2000
    --你的条件符号的也就只有两条,不知问什么
      

  7.   

    没为什么的,Oracle就是规定在where中不能用别名。还有,如果sale是number类型,你的sql改成
    select name,sale from store where sale <= 2000;
    会返回2条记录
      

  8.   

    问题的主要意思是,为什么在where子句中用别名会出错
      

  9.   

    因为SQL的运行原理是
       form -> where -> select 所以在where 中使用别名他不能识别