SELECT pm.id,
       pm.product_set_id,
       pm.product_model_code as product_number,
       pm.product_model_name as disp_name,
       pm.id as disp_sort,
       pm.product_model_name as product_name,
       1 as unit_code,
       pm.diameter_code as spec1,
       pm.length_code as spec2,
       NULL as spec3,
       NULL as spec4,
       NULL as spec5,
       24 as validity_priod,
       24 as max_validity_priod,
       100000 as public_price,
       14000 as cost_price,
       concat('0', pm.jan_code) as jan,
       concat('0', ps.uccean128_code, pm.uccean128_code) as purchase_jan,
       1 as quantity,
       1 as purchase_quantity,
       NULL as note,
       0 as invalid_flag_code,
       NULL as deleted_at,
       NOW() as created_at,
       NOW() as updated_at
FROM product_models as pm
LEFT JOIN product_sets as ps
     ON pm.product_set_id = ps.id
WHERE product_set_id=17
INTO OUTFILE "/tmp/products.csv" FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"';