$strSQL = "insert into detial1(contract,date_reg,tel_no,m_name,m_type,esn,m_code,phone_num,price,promotion,open_date,cut_date,terminate_date,run_no,billno,billdate,remark)
value (SELECT addr2.contract FROM addr2 WHERE addr2.run_no = ( SELECT max( run_no ) FROM addr2 )),
now(),
(SELECT detail_product.d_remark from detail_product,product WHERE detail_product.d_ens = '$esn'),
(SELECT product.p_name from detail_product,product WHERE detail_product.d_ens = '$esn'),
(SELECT product.p_type from detail_product,product WHERE detail_product.d_ens = '$esn'),
(SELECT detail_product.d_ens from detail_product,product WHERE detail_product.d_ens = '$esn'),
(SELECT product.p_id from detail_product,product WHERE detail_product.d_ens = '$esn'),
(SELECT detail_product.d_remark from detail_product,product WHERE detail_product.d_ens = '$esn'),
(SELECT product.p_price from detail_product,product WHERE detail_product.d_ens = '$esn'),
'$u_promotion',now(),'$cut_dat','$terminate_date','$run_no','$billno','$billdate','$remark' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");