2013-03-01 208 views
1

有人可以幫助我在此查詢中添加包含疾病風險因素的第三個表。該表是tblRiskFactors查詢MySQL數據庫

SELECT tblDiseases.disease 
FROM tblRel 
    LEFT JOIN tblDiseases ON tblRel.diseaseID = tblDiseases.diseaseID 
WHERE tblRel.symptomID = '1' AND tblRel.symptomID = '2' AND tblRel.symptomID ='3' 
+0

可不可以給表的結構? – 2013-03-01 08:40:53

+0

你真的需要給我們更多的去這裏。你能否提供三張桌子的結構以及你如何加入他們? – juco 2013-03-01 08:41:12

回答

0
SELECT tblDiseases.disease 
FROM tblRel 
     LEFT JOIN tblDiseases 
      ON tblRel.diseaseID = tblDiseases.diseaseID 
     LEFT JOIN tblRiskFactors 
      ON -- define the linking condition here 
WHERE tblRel.symptomID = '1' AND 
     tblRel.symptomID = '2' AND 
     tblRel.symptomID = '3' 

爲了進一步獲得更多的知識有關聯接,請訪問以下鏈接:

0
SELECT tblDiseases.disease as disease 
FROM tblRel 
    LEFT JOIN tblDiseases ON tblRel.diseaseID = tblDiseases.diseaseID 
    LEFT JOIN tblRiskFactors ON tblRel.relation_column = tblRiskFactors.relation_column 
WHERE tblRel.symptomID in (1,2,3)