SELECT from_unixtime(qrpls.start_dt) as Head_start, from_unixtime(qrpls.end_dt) as Head_end, qrplsl.exec_order, from_unixtime(qrplsl.from_dt) as Lines_From, from_unixtime(qrplsl.to_dt) as Lines_To, qrpls.*, qrplsl.*, trn.* FROM portaldb.qrpatrol_live_schedule qrpls inner join portaldb.qrpatrol_live_schedule_lines qrplsl on qrplsl.live_schedule_id = qrpls.id left outer join portaldb.qrpartol_transactions trn on trn.trn_id = qrplsl.tschres_ref_id where qrpls.cust_id = 2439 and create_time between '2015-05-01 16:30:01' and '2015-05-10 16:30:01';