select * from
((SELECT i.tran_date,item_code,transaction_no, i.in, i.out, price FROM `0p4_item_transaction` i)
union all
(SELECT h.date as 'tran_date',d.item_code,h.good_issue_note_no as 'transaction_no',null as 'in', d.gin_quantity as 'out', null FROM 0p4_good_issue_note_items d left join 0p4_good_issue_note h on h.id=d.good_issue_note_id where ifnull(d.gin_quantity,0) >0) ) t order by t.tran_date



select h.date,d.item_code,d.quantity,d.unit_price from 0p4_invoice_items d left join 0p4_invoice h on h.invoice_id=d.invoice_id
order by h.date



SELECT orderNumber,orderDate, status
FROM orders
INTO OUTFILE 'C:/tmp/orders.csv'
FIELDS ENCLOSED BY '"' TERMINATED BY ';' ESCAPED BY '"'
LINES TERMINATED BY '\r\n'
