表A
-----------------
a_id | user |
-----------------
1 |adam |
2 |jose |
3 |adam |
4 |adam |
5 |anne |
6 |jose |
表B
--------------------------------------
b_id | user | value1 | value2
--------------------------------------
1 |adam | 33 | 9
2 |jose | 46 |88
3 |adam | 77 |21
4 |adam | 81 |15
5 |anne | 11 |67
6 |jose | 45 |6
如何查看value1和value2的总值。
示例:我希望我的列表视图页面看起来像这样。
--------------------------------------------------------
user | total value of value1 | total value of value2
---------------------------------------------------------
adam |191 | 45
jose |91 | 94
anne |11 | 67
请。帮助
答案 0 :(得分:-1)
您可以尝试某种聚合查询,例如以下
SELECT user, SUM(value1) AS v1sum FROM B GROUP BY user