2012-01-10 43 views
1

img http://i43.tinypic.com/1pt91j.pngMySQL的加入援助

嗨,我努力創建一個查詢,這給飛行員的日程安排對於一個給定的一天。到目前爲止,我已經得到了

SELECT f.flight_date, l.lesson_date FROM Flight f JOIN lesson l ON f.pilot_idpilot = l.pilot_idpilot WHERE f.flight_date = CURDATE() OR l.lesson_date = CURDATE() AND pilot_idpilot = 7236; 

結果我得到的是

Lesson_id | lesson_date | pilot_idpilot | idFlight | flight_date | pilot_id_pilot 

有隻指定試點涉及例如活動類型的一種方式

Activity | Date | 

任何幫助將是可怕的!感謝球員/女孩

回答

1

如何:

SELECT 'Lesson' as Activity, lesson_date as Date 
FROM Flight f JOIN lesson l ON f.pilot_idpilot = l.pilot_idpilot 
WHERE l.lesson_date = CURDATE() AND pilot_idpilot = 7236 
UNION 
SELECT 'Flight' as Activity, flight_date as Date 
FROM Flight 
WHERE f.flight_date = CURDATE() AND pilot_idpilot = 7236; 
+0

感謝約翰我會跑,通過CMD和它的工作太棒了! – 2012-01-11 00:02:14