我正在尝试将多个表连接到一个非常大的表
SELECT * FROM
Person, Patient, vanster_implantat,
hoger_implantat, vanster_operationer,
hoger_operationer, vanster_processorpatient,
hoger_processorpatient, processor
由于彼此之间没有连接,因此会产生很多重复的值。我希望所有表都通过所有表所在的“数字”列以某种方式连接到“患者”表。我试图同时将所有表连接到表“ Patient”:
SELECT * FROM
Person, Patient, vanster_implantat, hoger_implantat, vanster_operationer, hoger_operationer, vanster_processorpatient, hoger_processorpatient WHERE
person.nummer = patient.nummer AND
patient.nummer = vanster_implantat.nummer AND
patient.nummer = hoger_implantat.nummer AND
patient.nummer = vanster_operationer.nummer AND
patient.nummer = hoger_operationer.nummer AND
patient.nummer = vanster_processorpatient.nummer AND
patient.nummer = hoger_processorpatient.nummer
但这导致没有数据,因为它要么已连接到所有表,要么什么都不显示。这是全有还是全无的情况。我想要它显示当前与其他表的连接,它可能是一个或多个连接。希望您理解我的意思,感谢您的帮助。
尝试
select
*
from
patient
left join
person on person.nummer = patient.nummer
left join
vanster_implantat on vanster_implantat.nummer = patient.nummer
left join
hoger_implantat on hoger_implantat.nummer = patient.nummer
left join
vanster_operationer on vanster_operationer.nummer = patient.nummer
left join
hoger_operationer on hoger_operationer.nummer = patient.nummer
left join
vanster_processorpatient on vanster_processorpatient.nummer = patient.nummer
left join
hoger_processorpatient on hoger_processorpatient.nummer = patient.nummer;
这是左外连接,主传动台为patient
。这基本上意味着,如果其他表不具有联接,则仍然可以。left
如果要确保该表中有匹配的记录,可以删除某些联接。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句