我似乎有一些問題讓我的多左連接給我正確的結果,它給了我的編號只是罰款但是我似乎無法得到鏈接給我的結果問題,而不是ID。MySQL中的多個左連接
下面的代碼。
SELECT
a.id as id,
a.clientid as clientid,
a.comp_id as compid,
a.title as title,
a.firstname as firstname,
a.lastname as lastname,
a.countrycode as countrycode,
a.mobile as mobile,
a.question1_answer as question1_answer,
a.question2_answer as question2_answer,
a.question3_answer as question3_answer,
a.timestamp as timestamp,
b.comp_name as comp_name,
b.comp_id as comp_id,
a.question1 as question1,
a.question2 as question2,
a.question3 as question3
FROM
competition_entries AS a
LEFT JOIN
competition as b
ON
a.comp_id = b.id
LEFT JOIN
questions as q
ON
a.question1 = q.question_id
AND
a.question2 = q.question_id
AND
a.question3 = q.question_id
WHERE
a.comp_id = '$download_id'
然而每次我打電話問題1 /問題2 /問題3 - 所示的結果僅是被對應於它們的ID的其他表中的數字值。
你得有'q.question_text'或任何字段名稱是...如果你不要在select的字段列表中列出字段,或者選擇*,數據庫不會給你任何不需要的字段。 –