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条答案
按热度按时间mw3dktmi1#
从http://www.mysqltutorial.org/mysql-having.aspx:
having子句在select语句中用于为一组行或聚合指定筛选条件。
你没有聚合,所以试试
WHERE
而不是HAVING
.pdtvr36n2#
这是因为你不知道´不必使用having(它仅用于聚合函数),必须在以下情况下使用: