我有3个独立工作查询,我怎么能,但他们作为一个
SELECT * , SUM(summa) AS papp9 FROM rent WHERE liige_id = 9 AND date > NOW()
SELECT * , SUM(summa) AS papp8 FROM rent WHERE liige_id = 8 AND date > NOW()
SELECT * , SUM(summa) AS papp7 FROM rent WHERE liige_id = 7 AND date > NOW()
答案 0 :(得分:2)
试试这个:
SELECT * , SUM(summa) AS papp FROM rent WHERE date > NOW()
group by liige_id
答案 1 :(得分:1)
SELECT *, SUM(summa) AS papp9
FROM rent
WHERE liige_id IN (7,8,9)
AND date > NOW()
GROUP BY liige_id