1

前の質問の Employee テーブルと Department テーブルの使用

本社と研究部門で働く従業員数を示す別の結合テーブルを作成しようとしています。

これまでにこれを試しましたが、having 句でエラーが発生し続けます。助言がありますか?

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
4

1 に答える 1

2

句で使用INします。WHERE

SELECT...
FROM...
WHERE d.dname IN ('Headquarters','Research')
GROUP BY...
于 2012-12-09T01:45:09.510 に答える