我在mysql中尝试一个简单的查询,我收到一个语法错误,需要帮助理解。
SELECT
eea.*,
ee.description,
eect.title,
eect.file,
eect.location,
eect.img_location
FROM
`e_exam` ee,
`e_exam_attempt` eea,
`e_exam_cert_template` eect
WHERE
eea.a_user_id = 1,
eea.ee_id = ee.id,
ee.eect_id = eect.id;
我收到以下错误:
基本上是第13行的语法错误
eea.ee_id = ee.id, ee.eect_id = eect.id LIMIT 0, 25
任何人都知道如何编辑这个以获得-1票改善?
答案 0 :(得分:0)
它是一个简单的语法错误,您的WHERE子句不应该用逗号分隔。使用AND或OR等
SELECT
eea.*, ee.description, eect.title, eect.file,
eect.location,eect.img_location
FROM
`e_exam` ee,
`e_exam_attempt` eea,
`e_exam_cert_template` eect
WHERE
eea.a_user_id = 1 AND
eea.ee_id = ee.id AND
ee.eect_id = eect.id
LIMIT 0,25
您还应该了解JOIN语法
SELECT
eea.*, ee.description, eect.title,eect.file,
eect.location, eect.img_location
FROM `e_exam_attempt` eea
JOIN `e_exam` ee ON eea.ee_id = ee.id
JOIN `e_exam_cert_template` eect ON ee.eect_id = eect.id
WHERE
eea.a_user_id = 1
LIMIT 0,25