在SQL中使用多个内部联接

前端之家收集整理的这篇文章主要介绍了在SQL中使用多个内部联接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
运行以下查询时,我收到错误消息

Syntax error (missing operator) in query expression
‘diagnosis.Patient_No = ‘Patient_No INNER JOIN Illness ON
Illness.Illness_Code = Diagnosis.Illness_Code’

SELECT Patient.Last_Name AS LastName,Patient.First_Name AS FirstName,Patient.Gender AS Gender,Patient.Age AS Age,Illness.Illness_Desc AS illness,Medication.Medication_Desc AS Medication,Prescription.Dosage AS Dosage
FROM Patient
INNER JOIN Diagnosis ON Patient.Patient_No = Diagnosis.Patient_No
INNER JOIN Illness ON Diagnosis.Illness_Code = Illness.Illness_Code
INNER JOIN Prescription ON Patient.Patient_No = Prescription.Patient_No
INNER JOIN Medication ON Prescription.Medication_code = Medication.Medication_code

我确认sick_code都在疾病和诊断表中,一切都应该有效吗?不确定在这次加入期间我是否需要将这些疾病代码添加到select语句中?我尝试将它们添加到我的Select中,这对我来说似乎也没有用.

解决方法

Medication.Medication_Desc AS Medication,Prescription.Dosage AS Dosage

看起来您没有在FROM语句中加入药物和处方表.

原文链接:https://www.f2er.com/mssql/78898.html

猜你在找的MsSQL相关文章