我有一个查询
SELECT
count(product) as amount,
product,
sum(price) AS price
FROM `products`
WHERE
brid = 'broker'
AND
cancelled is null
GROUP BY product
WITH ROLLUP
是否可以查询一个表以获取代理 ID,然后为每个代理运行上面写为 1 个查询的查询?
几乎像:
SELECT brid FROM membership
THEN
SELECT
count(product) as amount,
product,
sum(price) AS price
FROM `products`
WHERE
brid = membership.brid
AND
cancelled is null
GROUP BY product
WITH ROLLUP
THEN
SELECT NEXT brid
这可能吗?我知道如何在 PHP 中做到这一点,但我更喜欢 1 个可以创建数组的查询,而不是每个查询的大量查询。
谢谢亚当。