gpt4 book ai didi

mysql - 连接两个表

转载 作者:行者123 更新时间:2023-12-01 00:10:09 25 4
gpt4 key购买 nike

<分区>

我有两个表:'Project' 和 'Project Monthly'。

| PROJECT_ID |  TITLE |    | ID | PROJECT_ID |  MONTH | EXPENSE |
----------------------- --------------------------------------
| 1 | title1 | | 1 | 1 | 1 | 100 |
| 2 | title2 | | 2 | 1 | 2 | 2000 |
| 3 | title3 | | 3 | 1 | 3 | 900 |
| 4 | 1 | 4 | 900 |
| 5 | 2 | 1 | 200 |
| 6 | 2 | 2 | 200 |
| 7 | 3 | 1 | 500 |

我想要一个这样的表:

| PROJECT_ID |  TITLE | MONTH_1 | MONTH_2 | MONTH_3 | MONTH_4 |
---------------------------------------------------------------
| 1 | title1 | 100 | 2000 | 900 | 900 |
| 2 | title2 | 200 | 200 | NULL| NULL|
| 3 | title3 | 500 | NULL | NULL| NULL|

只用JOIN不带子查询能实现吗?

谢谢!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com