img http://i43.tinypic.com/1pt91j.png
嘿伙计们,我正在努力创建一个查询,给出某一天飞行员的时间表。到目前为止我已经
了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 |
任何帮助都会很棒!谢谢你们/女孩
答案 0 :(得分: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;