所以我有以下查询:
'SELECT *, upload.id AS id, report.id AS report_id, (SELECT COUNT(*)
FROM upload WHERE report.upload_id = upload.id) AS nums FROM upload
LEFT JOIN report ON upload.id=report.upload_id WHERE private="0" '
我对如何计算每次上传的报告有疑问。此查询需要计算给定上传的所有报告,并在获取时返回所有上传。由于某种原因,每次插入新报告而不是添加到总数中时,我都会重复上传。见下图:
请注意,对于与给定上传相关的每个报告,console (1).png 如何显示三次......真的我希望它显示一次,然后侧面的计数应该是(3)。任何帮助将非常感激!!