跨两个表sql执行select count
我有一种表关系,将一个人与许多亲戚联系起来。所以表是 1. 客户端。 2. 相对客户。我想显示 Persons 表的所有行,同时显示每个人有多少亲戚的计数。我有这样的疑问: <代码> SELECT c.clientid, c.fname, c.lname, count(cr.relativeid) asrelativecount FROM {client} AS c INNER JOIN {client_relative} cr on c.clientid = cr.clientid
这不起作用。有什么想法吗?
I have a table relationship which links one person to many relatives. so the tables are 1. Client. 2. Client_relative. I want to display all the rows of the Persons table, while displaying a count of how many relatives each person has. I have this query:
SELECT c.clientid, c.fname, c.lname, count(cr.relativeid) as relativecount FROM {client} AS c INNER JOIN {client_relative} cr on c.clientid = cr.clientid
This isn't working. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)