2016-08-05 56 views
-1

我正在嘗試一個簡單的查詢在mysql中,我得到一個語法錯誤,我需要幫助理解。MySQL SELECT語法錯誤沒有看到

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; 

我收到以下錯誤:

picture of error from my vm

基本上上線13

eea.ee_id = ee.id, ee.eect_id = eect.id LIMIT 0, 25 
+0

請[編輯]你的問題,並添加錯誤文本。 –

+2

**我看不到任何船隻**或任何LIMIT子句 – RiggsFolly

+0

哪裏想要AND,OR等,而不是逗號 –

回答

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 

You should also learn about the JOIN syntax

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 
+0

謝謝,剛剛意識到缺少的AND。 – Geodin