SELECT	ad.id,
	ad.adjustment_id as adjustment_id,
	ad.adjustment_sub_code as seq_number,
	adj.hospital_id as stock_type_code_1,
	ad.adjustment_type_id as stock_type_code_2,
	ps.product_category_id as product_category_id,
	ad.product_set_id as product_set_id,
	ad.product_model_id as product_id,
	ad.lot_number as lot_number,
	'' as serial_number,
	ad.ubd_date as ubd,
	24 as validity_period,
	1 as unit_code,
	ad.adjustment_quantity as quantity,
	NULL as products_price_id,
	ad.adjustment_detail_note as note,
	NOW() as created_at,
	NOW() as updated_at
FROM adjustment_details as ad
LEFT JOIN master_app_production.product_sets as ps
	ON ad.product_set_id = ps.id
LEFT JOIN adjustments as adj
	ON ad.adjustment_id = adj.id
INTO OUTFILE "/tmp/adjustment_details.csv" FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"';