在此查询中,只有一条记录显示pls help ...
("SELECT p.project_name, p.category, p.status, count(b.developer_id) AS developer_id
FROM project p , bidding b
WHERE p.project_id=b.bid_id AND p.client_reg_id='"+LID+"'");
答案 0 :(得分:0)
COUNT是一个聚合函数,总是将几个寄存器组合到一个寄存器中。从查询中删除它,您将看到所有行。 http://dev.mysql.com/doc/refman/5.6/en/group-by-functions.html#function_count
中的更多信息("SELECT p.project_name, p.category, p.status, b.developer_id AS developer_id
FROM project p , bidding b
WHERE p.project_id=b.bid_id AND p.client_reg_id='"+LID+"'");
试试这个:
SELECT p.project_name, p.category, p.status, count(b.developer_id) AS developer_bid_count
FROM project p
INNER JOIN bidding b
ON p.project_id = b.bid_id
WHERE p.client_reg_id='"+LID+"'
GROUP BY p.project_id
我假设project_id是project
表中的主键。当我们指定group by
字段时,如果此字段是主键,则查询将为每个项目返回一行,计算每个开发人员的出价数量