我的数据库结构:
每个“wp_custombill”都有多个“wp_customuser”
我想查询所有的custombill,每个custombill 都有其customuser 的总和。我的查询是
select cb.ID, cb.Description, cb.amount, SUM(cu.amount)
from wp_customuser as cu
inner join wp_custombill as cb
on cu.email = cb.Email
group by cb.ID, cb.Description, cb.amount
最佳答案
我猜你的 wp_custombill
ids (1,2,3) 有相同的 email
但是没有数据样本是很难测试的。
否则你的查询看起来没问题。
关于mysql - MySQL 中的这个 group by 查询有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32470572/