|  |  | 
            
              | หา ฟีลด์สำคัญที่เหมือนกัน นำมา union กัน จัดเรียงด้วย วันที่เวลา แสดงเป็น รายสินค้า
 
 Code (SQL)
 
 
select * from (
select product_id,  'ยกมา' as description, last_update, balance, 0 as product_in, 0 as product_out from balance where product_id='1234'
union all
select product_id, 'ซื้อสินค้่า', buydate , 0, quantity, 0 from `สินค้าเข้า`  where product_id='1234'
union all
select product_id, 'ขายสินค้า', saledate , 0, 0, quantity from `สินค้าออก`  where product_id='1234'
) as t order by last_update
 แล้วใช้ main code บวกลบ แสดงรายงาน
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2018-09-13 06:37:44 | By :
                            Chaidhanan |  |  |  
                  |  |  |  |  |  |  |