我有以下查詢連接的列。排除MySQL查詢
該查詢返回以下:
staff_availability_id staff_id day_id time_from(join) time_to(join) day time_from (alias) time_to (alias)
有什麼辦法,我可以排除的結果聯接列?
我有以下查詢連接的列。排除MySQL查詢
該查詢返回以下:
staff_availability_id staff_id day_id time_from(join) time_to(join) day time_from (alias) time_to (alias)
有什麼辦法,我可以排除的結果聯接列?
你必須手動選擇它們。
改變這種
SELECT sa.*
到
SELECT sa.staff_availability_id , sa.staff_id,....--what ever you want to select and dont select those you mentioned
** facepalm **謝謝@回聲我,我甚至沒有看到,因爲它幾乎凌晨4點 – nikmav
你歡迎:)。 –
選擇列如,
SELECT sa.staff_availability_id ,sa.staff_id,d.day, TIME_FORMAT(timefrom.time, '%H:%i') AS time_from, TIME_FORMAT(timeto.time, '%H:%i') AS time_to
FROM staff s
INNER JOIN staff_availability sa
ON sa.staff_id = s.staff_id
INNER JOIN days d
ON d.day_id = sa.day_id
LEFT JOIN time_slots AS timefrom
ON timefrom.time_slot_id = sa.time_from
LEFT JOIN time_slots AS timeto
ON timeto.time_slot_id = sa.time_to
INNER JOIN users u
ON s.user_id = u.user_id
WHERE u.user_id = :user_id
只是列出你想要的列了'select'子句。 –