SELECT t.id, apa.district AS district
FROM tbl_activity AS t
JOIN tbl_activity_package AS ap ON ap.activity_id = t.id
JOIN tbl_activity_package_address AS apa ON apa.activity_package_id = ap.id
GROUP BY t.id
ORDER BY apa.district
查詢後,輸出爲:SQL - 避免重複的列的值
我想通過區返回只有一行。我怎麼能在查詢中做到這一點?
指定'DISTINCT'(也不要在區域中選擇'id',因爲'<117, Evora>'__不與'<118, Evora>'相同] –
你關心哪個'id'值與「Evora」一起返回? –
@AlmaDo'DISTINCT'不會改變任何東西。 –