mysql - 获取数据时出现连接问题
问题描述
我有三个表和结构如下:
- 美国广播公司
id name education
1 test1 a
2 test2 b
3 test3 c
- pqr
id name abcid
1 takr 1
2 test21 1
3 testlll 2
- xyz
id name abcid
1 takr 2
2 test21 2
3 testlll 3
我想要所有基于 abc 表 id 的数据
下面是查询
SELECT d.ID,l.VALUE_ID as RI_ID,l.UF_CRM_1486370412 as RI_AMT, f.VALUE_ID as Finance_Id , f.UF_CRM_1595053941 as FI_AMT
FROM b_uts_crm_lead as l
JOIN b_crm_deal as d
ON d.ID = l.UF_CRM_1600342528
JOIN b_uts_crm_financeaddition as f
ON d.ID = f.UF_CRM_1600350766
解决方案
我猜你想要left join
:
select . . . -- the columns you want
from abc left join
xyz
on xyz.abcid = abc.id left join
pqr
on pqr.abcid = abc.id;
推荐阅读
- arrays - UITableView 中的 UICollectionView - 我想在 CollectionVewCell 中显示数据
- javascript - 为什么 Jest 中的分支没有被其余参数覆盖?
- android - 如何为引用属性设置默认值?
- nginx - 如何在 80 以外的其他端口上运行 Nginx
- php - 使用 PHP 创建子域以启用 CNAME 记录
- python - cppyy 安装失败
- php - 在 CSS 表上循环 mysql 表值
- hive - 如何修复 org.apache.kafka.common.config.ConfigException:缺少没有默认值的必需配置“group.id”
- scala - 代码片段中的“for”循环无法理解
- hashicorp-vault - 使用 Hashicorp 保险库时如何以及在何处放置 Tessera 私钥的密码