首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MySQL连接-没有结果

MySQL连接-没有结果
EN

Stack Overflow用户
提问于 2014-03-13 21:18:47
回答 1查看 30关注 0票数 0

我很确定这与我选择的表或联接的顺序有关,但是在我的查询中尝试了各种重新排序之后,我仍然坚持0的结果。

有人能给我指明正确的方向吗?

表A(返回355个结果):

代码语言:javascript
复制
SELECT DISTINCT
    person.person_id as "Person ID",
    CONCAT(person.last, ', ', person.first) as "Patient Name",
    person.birthday as "Birthday",
    person_ins_tie.insurance_id as "Insurance ID",
    insurance.carrier as "Carrier",
    insurance.phone as "Carrier Phone Number"
FROM
    person
        JOIN
    person_ins_tie ON person.person_id = person_ins_tie.person_id
        JOIN
    insurance ON person_ins_tie.insurance_id = insurance.insurance_id
WHERE
    insurance.carrier LIKE 'Blue%'

表B(返回0结果/没有错误):

代码语言:javascript
复制
SELECT DISTINCT
    person.person_id as 'Person ID',
    patient.display_id as 'Chart #',
    CONCAT(person.last, ', ', person.first) as 'Patient Name',
    person.birthday as 'Birthday',
    insurance.insurance_id as 'Insurance ID',
    insurance.carrier as 'Carrier',
    insurance.phone as 'Carrier Phone Number'
FROM
    person
        JOIN
    person_ins_tie ON person.person_id = person_ins_tie.person_id
        JOIN
    insurance ON person_ins_tie.insurance_id = insurance.insurance_id
        JOIN
    patient ON person.person_id = patient.person_id
WHERE
    insurance.carrier LIKE 'Blue%'

我很感谢你的反馈!

EN

回答 1

Stack Overflow用户

发布于 2014-03-13 21:30:52

JOIN的意思是INNER JOIN

在本例中,当您加入patient表时,它尝试在person_id of patient表中从person表中找到person_id。因此,这里唯一的可能是在person_id表的person_id列中找不到来自上一个联接集的person_id。所以记录是0!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22391130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档