SELECT
	dd.id,
	dd.disposal_id,
	dd.disposal_sub_code as seq_number,
	ps.product_category_id as product_category_id,
	dd.product_set_id as product_set_id,
	dd.product_model_id as product_id,
	dd.lot_number as lot_number,
	'' as serial_number,
	dd.ubd_date as ubd,
	24 as validity_period,
	1 as unit_code,
	dd.disposal_quantity as quantity,
	NULL as products_price_id,
	dd.disposal_detail_note as note,
	NOW() as created_at,
	NOW() as updated_at
FROM disposal_details as dd
LEFT JOIN master_app_production.product_sets as ps
	ON dd.product_set_id = ps.id
LEFT JOIN disposals as d ON dd.disposal_id=d.id
WHERE d.disposal_date BETWEEN "2011-03-01" AND "2011-03-31"
INTO OUTFILE "/tmp/disposal_details.csv" FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"';