版权说明:作者:张颖希(PocketZ's Blog)出处:http://www.cnblogs.com/PocketZ本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利. 问题 前面已经使用了别名为查询提供更有意义的列名,而且也使用WHERE子句将一些数据排除掉,然而,我们还想在WHERE子句中引用别名. select sal as salary, comm as commission from emp w
如下查询,会抛出错误:mysql> select sal as salary, comm as commission from emp where salary < 5000;ERROR 1054 (42S22): Unknown column 'salary' in 'where clause'解决方案 将查询作为内联视图就可以就可以引用其中别名的列了:select *from ( select sal as salary, comm as commission from
如下查询,会抛出错误: mysql> select sal as salary, comm as commission from emp where salary < 5000;ERROR 1054 (42S22): Unknown column 'salary' in 'where clause' 解决方案 将查询作为内联视图就可以就可以引用其中别名的列了: select *from ( select sal as salary, comm as commission from
此问题的原因是因为表的列名称使用了Oracle声明的关键字,列名起的不好引起的. 如果列很多,又不好确定是哪个列名使用了关键字,以下建议可供参考: select * from v$reserved_words where keyword in( select COLUMN_NAME from all_tab_columns where table_name = 'HP_FFS' and owner='用户名大写' ); 除了与oracle关键字段冲突错误外(select * from v$res