Reputation: 351
Using the Employee and Department tables from previous question
I'm trying to build another combined table showing the number of employees that work in the headquarters and research departments.
I've tried this so far but keep getting errors on my having clause. Any suggestions?
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
Upvotes: 1
Views: 97
Reputation: 263723
use IN
in WHERE
clause.
SELECT...
FROM...
WHERE d.dname IN ('Headquarters','Research')
GROUP BY...
Upvotes: 2