问题遇到的现象和发生背景
MYSQL 表 USER ,SUM,MONEY;
USER 表结构为 UID NAME;
id | UID | NAME
1 | 1 |张三
2 | 2 |李四
3 | 3 |王五
JIFEN表结构为 UID USER SUM0;
id | UID | USER | SUM0
1 | 1 |张三 |5
2 | 1 |张三 |2
3 | 2 |李四 |5
4 | 2 |李四 |5
5 | 3 |王五 |2
6 | 3 |王五 |2
MONEY表结构为 UID USER SUM1;
id | UID | USER | SUM 1
1 | 1 |张三 |6
2 | 1 |张三 |7
3 | 2 |李四 |2
4 | 2 |李四 |7
5 | 3 |王五 |6
6 | 3 |王五 |6
希望查询结果为
UID | NAME |SUM0 |SUM1
1 |张三 | 7 | 13
2 |李四 | 10 | 9
3 |王五 | 4 | 12
即以 UID 或NAME为条件,获取 JIFEN及MONEY表内对应UID 或NAME 的 SUM0 及SUM1 的统计结果