1
使用Employee和Department表從previous questionhaving子句問題
我試圖建立顯示,在總部和研發部門工作的僱員數量相互結合表。
我已經試過這個目前爲止,但不斷收到我有條款的錯誤。有什麼建議麼?
mysql> select e.fname, d.dname
-> from department d
-> inner join employee e on e.dno = d.dnumber
-> group by e.fname
-> having d.dname='Headquarters','Research';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to
use near ''Research'' at line 5
mysql> select e.fname, d.dname
-> from department d
-> inner join employee e on e.dno = d.dnumber
-> group by e.fname
-> having d.dname=1,5;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to
use near '5' at line 5
不是爲了分割頭髮,但是可以用having子句做到嗎? – SkyVar
嘗試它並查看'SELECT ... FROM ... GROUP BY ... HAVING d.dname IN('Headquarters','Research')' –