我对自己几乎完成的几张表有一个相当复杂的查询。最后一个方面只涉及汇总一个项目收到的投标数量,不过我正在为特定部分中的所有项目执行此操作。查询工作正常,除了当我尝试将聚合 (/* */) 添加到查询时它只返回 1 行。阅读它似乎我需要一个子查询,但我不完全确定如何去做。这是迄今为止的查询:
SELECT s.id as section_id, s.name as section, i.id as item_id,
i.title as item_title, item.location_id as item_location_id,
i.slug as item_slug, i.description as item_description,
i.price as item_price, UNIX_TIMESTAMP(i.date_added) as item_date_added,
c.id, c.city, c.particular_id, p.id, p.particular /*,COUNT(o.i_id) as interest*/
FROM section as s
INNER JOIN item as i
ON s.id = i.section_id
INNER JOIN city as c
ON i.location_id = c.id
INNER JOIN particular as p
ON c.particular_id = p.id
/*LEFT JOIN offer as o
ON o.job_id = i.id*/
WHERE s.id = 2
该代码的工作原理是它返回我期望的所有行,直到引入 /* */ 代码,现在它只返回 1 行。
您能给我的任何帮助将不胜感激
谢谢
强尼