MySQL JoinWhere 关联不存在
我获得了 2011 年有预约的网站客户的客户 ID。
SELECT customers.id
FROM customers
INNER JOIN sites ON customers.id = sites.customer_id
INNER JOIN appointments ON appointments.site_id = sites.id
WHERE YEAR(appointments.day) = 2011
我希望获得 2011 年没有任何预约的客户。对如何去做感到困惑。
I get customer ids for customers with sites that have appointments in 2011
SELECT customers.id
FROM customers
INNER JOIN sites ON customers.id = sites.customer_id
INNER JOIN appointments ON appointments.site_id = sites.id
WHERE YEAR(appointments.day) = 2011
I'm looking to get customers who don't have any appointments in 2011. Confused on how to go about it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有几种方法:
或者:
A couple of ways:
or:
...哪里不是年份(约会.日) = 2011
...WHERE NOT YEAR(appointments.day) = 2011
应该做一个答案而不是编辑。由于缩放,不想真正寻找 NULL。
Should have done an answer instead of an edit. Don't really want to look for NULL's due to scaling.
请检查您的特定数据库服务器是否有“<>”这是“不等于”。
Please check your specific database server for "<>" which is "not equal".