2014-05-10 138 views
2

我有以下查詢連接的列。排除MySQL查詢

該查詢返回以下:

staff_availability_id staff_id day_id time_from(join) time_to(join) day time_from (alias) time_to (alias) 

有什麼辦法,我可以排除的結果聯接列?

+2

只是列出你想要的列了'select'子句。 –

回答

1

你必須手動選擇它們。

改變這種

SELECT sa.* 

SELECT sa.staff_availability_id , sa.staff_id,....--what ever you want to select and dont select those you mentioned 
+0

** facepalm **謝謝@回聲我,我甚至沒有看到,因爲它幾乎凌晨4點 – nikmav

+0

你歡迎:)。 –

0

選擇列如,

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