Reputation: 31
There are two tables as below
employee table: empid, empname, deptid
department table: deptid, deptname
then write query to "list all employees for dept name=computer"
Upvotes: 1
Views: 18704
Reputation: 11
SELECT empname, deptname
from employee, department
where employee.deptid=department.deptid
and department.deptname='computer';
Computer must be case sensitive as per your values in your table
Upvotes: 1
Reputation: 2833
SELECT e.empname, deptname
FROM employee e
INNER JOIN department d
ON e.deptid = d.deptid
GROUP BY emptname, deptname
Upvotes: 0
Reputation: 263733
this should be pretty straight forward,
SELECT a.empid, a.empname, b.deptname
FROM employee a
INNER JOIN department b
ON a.deptid = b.deptid
ORDER BY b.deptname, a.empname
To further gain more knowledge about joins, kindly visit the link below:
Upvotes: 3