MySQL-Haveing子句中的未知列ename

时间:2018-06-30 09:00:23

标签: mysql having

MariaDB [testingcampus]> select * from employee;

+-----+--------+-----------+--------+
| EID | Ename  | City      | salary |
+-----+--------+-----------+--------+
| 100 | smith  | Bangalore |  10000 |
| 101 | carl   | Bangalore |  12000 |
| 102 | Ram    | Chennai   |  12000 |
| 103 | pankaj | Hyderabad |   5000 |
| 104 | vikram | Pune      |   2000 |
+-----+--------+-----------+--------+
5 rows in set (0.00 sec)

对于上表,当我键入以下代码时,我得到一个错误

MariaDB [testingcampus]> Select eid from employee having ename= "Vikram";
ERROR 1054 (42S22): Unknown column 'ename' in 'having clause'

2 个答案:

答案 0 :(得分:1)

这是因为您不必使用hading(它仅用于聚合函数),因此必须使用 where ,如下所示:

<script type="text/javascript">
document.writeln('<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width=' 
+ 720 + ' height=' + 480 + ' 
CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">');
document.writeln('<param name="autoplay" value="true">');
document.writeln('<param name="controller" value="true">');
document.writeln('<param name="qtsrc" value="' + 
'rtsp://192.168.1.90:554/user=admin&password=&channel=01&stream=0.sdp' + '">');
</script>

答案 1 :(得分:0)

来自http://www.mysqltutorial.org/mysql-having.aspx

  

在SELECT语句中使用HAVING子句为一组行或集合指定过滤条件。

您不进行汇总,因此请尝试使用WHERE而不是HAVING