我在mysql数据库中有两个表,"points“和"userpoints”。e.g
点数:
id | pointvalue | message
----------------------------
1 | 5 | comment用户点:
id | uid |pid | timestamp
-------------------------
89 | 5 | 1 | timestamp当userpoints中的pid链接到userpoints表时,我如何获得userpoints表中的点数总和?
使用mysql查询?
发布于 2011-09-14 18:22:10
SELECT up.uid, SUM(p.pointvalue) total_points
FROM Userpoints up
LEFT JOIN Points p
ON up.pid = p.id
WHERE up.uid = 5;发布于 2011-09-14 18:20:51
select sum(p.pointvalue) from userpoints up left join points p on up.pid = p.id group by up.uid
https://stackoverflow.com/questions/7414626
复制相似问题