我想将parsed_param
传递给嵌套选择。像这样 。
select name ,ord.sq,ord.sp ,sandwich_id as parsed_param
from sandwiches , (select sum(quantity) as sq, sum(total_price) as sp
from order_sandwiches
where sandwich_code=parsed_param) as ord
order by parsed_param
最佳答案
尝试这个
SELECT sandwiches.name,
sandwiches.sandwich_id,
sum(order_sandwiches.quantity) as sq,
sum(order_sandwiches.total_price) as sp
FROM sandwiches
JOIN order_sandwiches ON order_sandwiches.sandwich_code = sandwiches.sandwich_id
GROUP BY sandwiches.name, sandwiches.sandwich_id
ORDER BY sandwiches.sandwich_id
关于mysql - 如何在mysql中解析值以嵌套选择,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9924508/