【发布时间】:2017-08-27 22:41:14
【问题描述】:
【问题讨论】:
-
您实际尝试了什么?您能发布您使用的确切 SQL 语句吗?
标签: mysql sql database request linked-tables
【问题讨论】:
标签: mysql sql database request linked-tables
您可以使用GROUP BY 进行INNER JOIN,例如:
SELECT s.number AS supplier, c.category AS category, s.date as `date`, COUNT(r.*)
AS total
FROM supplier s JOIN register r ON s.id = r.supplier_id
JOIN category c ON c.id = r.category_id
GROUP BY s.number, c.category, s.date;
【讨论】:
假设链接服务器名称为 [LinkedSample\Tables] 然后就可以使用下面的代码了:
SELECT s.number AS supplier, c.category AS category, s.date as `date`, COUNT(r.*) AS total
FROM [LinkedSample\Tables].supplier s
JOIN [LinkedSample\Tables].register r ON s.id = r.supplier_id
JOIN [LinkedSample\Tables].category c ON c.id = r.category_id
GROUP BY s.number, c.category, s.date;
【讨论】: