select id from tms_dispatch_order where create_by = 'admin'

select * from tms_trip where dispatch_order_id  in (select id from tms_dispatch_order where create_by = 'admin');
delete from tms_trip where dispatch_order_id  in (select id from tms_dispatch_order where create_by = 'admin');

select * from tms_driver_dispatch where  dispatch_id  in (select id from tms_dispatch_order where create_by = 'admin')
delete from tms_driver_dispatch where  dispatch_id  in (select id from tms_dispatch_order where create_by = 'admin');

select * from tms_car_key_dispatch where  dispatch_order_id  in (select id from tms_dispatch_order where create_by = 'admin')
delete from tms_car_key_dispatch where  dispatch_order_id  in (select id from tms_dispatch_order where create_by = 'admin');

select * from tms_finance_detail where  dispatch_order_id  in (select id from tms_dispatch_order where create_by = 'admin')
delete from tms_finance_detail where  dispatch_order_id  in (select id from tms_dispatch_order where create_by = 'admin');
select * from tms_finance where  dispatch_id  in (select id from tms_dispatch_order where create_by = 'admin')
delete from tms_finance where  dispatch_id  in (select id from tms_dispatch_order where create_by = 'admin');
select * from tms_receivable_fee where  dispatch_id  in (select id from tms_dispatch_order where create_by = 'admin')
delete from tms_receivable_fee where  dispatch_id  in (select id from tms_dispatch_order where create_by = 'admin');
select * from tms_quote_fee where  dispatch_id  in (select id from tms_dispatch_order where create_by = 'admin')
delete from tms_quote_fee where  dispatch_id  in (select id from tms_dispatch_order where create_by = 'admin');

select * from tms_ar_bill where  id  in (select bill_id from tms_ar_bill_item where  dispatch_no  in (select dispatch_no from tms_dispatch_order where create_by = 'admin'))
delete from tms_ar_bill where  id  in (select bill_id from tms_ar_bill_item where  dispatch_no  in (select dispatch_no from tms_dispatch_order where create_by = 'admin'))



select * from tms_ar_settlement where  bill_id  in (select bill_id from tms_ar_bill_item where  dispatch_no  in (select dispatch_no from tms_dispatch_order where create_by = 'admin'))
delete from tms_ar_settlement where  bill_id  in (select bill_id from tms_ar_bill_item where  dispatch_no  in (select dispatch_no from tms_dispatch_order where create_by = 'admin'))


select * from tms_ar_bill_item where  dispatch_no  in (select dispatch_no from tms_dispatch_order where create_by = 'admin')
delete from tms_ar_bill_item where dispatch_no  in (select dispatch_no from tms_dispatch_order where create_by = 'admin')

delete from tms_dispatch_order where create_by = 'admin'











