首页 > 解决方案 > 获取数据时出现连接问题

问题描述

我有三个表和结构如下:

  1. 美国广播公司
     id name    education
     1  test1   a
     2  test2   b
     3  test3   c
  1. pqr
    id  name    abcid
    1   takr    1
    2   test21  1
    3   testlll 2
  1. 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

标签: mysqlsql

解决方案


我猜你想要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;

推荐阅读