【发布时间】:2021-04-16 13:20:45
【问题描述】:
我有一个表格,其中包含有关用户每次使用移动或网络应用程序的一些信息,即
| id | platform |
|---|---|
| 1 | web |
| 1 | mobile |
| 2 | web |
| 2 | web |
我想用这个表加入另一个表,该表说明每个用户用作 phone_model 的内容
| id | phone_model |
|---|---|
| 1 | iphone |
| 2 | android |
但我想有条件地加入这些,以便只有移动条目显示 phone_model 和 web 行保持为空,即仅在平台 = 'mobile' 的情况下加入该信息
| id | platform | phone_model |
|---|---|---|
| 1 | web | |
| 1 | mobile | Iphone |
| 2 | web | |
| 2 | web |
我该怎么做?
【问题讨论】:
标签: sql postgresql join conditional-statements