我的尝试是返回那些有“is_read = 0”电子邮件的人的信息:
SELECT
a.*, b.*,c.*, COUNT(a.EmailNum) as NumEmails
FROM
Emails.emails a
inner join
Employees.user b on a.ID=b.id
inner join
Employees.dept c on b.dept=c.deptid
where
a.is_read='0'and c.deptName='HR';
group by
b.id
电子邮件。电子邮件(表):
emailNum, id, emailcontent,receivers
1 , 11, "sasa" ,sa@gmail.com
雇员:
user(Table)
userId, firstName, lastName, dept
1` , 'John' , 'Brown', 55
雇员:
dept(Table)
deptId, deptName
55 , 'HR'
我的尝试给出了:
emailNum, id , emailcontent, receivers, userId, firstName, lastName, dept, deptId, deptName
null , null, null , null , null , null , null , null , 55 , 'HR'
但我希望它不会返回任何东西!
谢谢