我很确定这与我选择的表或联接的顺序有关,但是在我的查询中尝试了各种重新排序之后,我仍然坚持0的结果。
有人能给我指明正确的方向吗?
表A(返回355个结果):
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结果/没有错误):
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%'我很感谢你的反馈!
发布于 2014-03-13 21:30:52
JOIN的意思是INNER JOIN。
在本例中,当您加入patient表时,它尝试在person_id of patient表中从person表中找到person_id。因此,这里唯一的可能是在person_id表的person_id列中找不到来自上一个联接集的person_id。所以记录是0!
https://stackoverflow.com/questions/22391130
复制相似问题