MySql 计数无法显示 0 值
我有两张桌子,一张 员工和邮件订阅 员工看起来像这样:
姓名(pk)|姓氏 | 邮寄年龄
订阅
MailId (pk)|员工姓名(外籍)|描述| 日期
我想要每个客户的订阅号的
Select COUNT(c.Name)
From Employee
INNER JOIN mailingSubscriptions as m ON c.Name = m.EmployeeName;
,因此我尝试了以下查询:它将为我提供在邮件订阅中拥有条目的每个员工的所有计数。
我的问题是我想查看所有员工的计数,包括那些没有条目的员工(因此显示 0),我尝试了外部左/右连接,但它不起作用。我做错了什么吗?
I have two tables one
Employee and mailing Subscriptions
Employee looks like this:
Name (pk) | Surname | Age
mailing Subsriptions
MailId (pk)| EmployeeName (fk)|Description | Date
I wanted to subscription number for each customer, therefore I tried the following query:
Select COUNT(c.Name)
From Employee
INNER JOIN mailingSubscriptions as m ON c.Name = m.EmployeeName;
It will give me all counts for each Employee that has an entry in the mailing subscription.
My problem is that I want to see the counts for ALL the Employees, including the ones without an entry (therefore to show 0), I tried an outer left/right join, but it will not work. Am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)