基本上,我想插入表中,从同一个表中获取值 id,像这样
$sql = ("INSERT INTO commande (idfichecmd,idproduit,idclt,qte,datecmd)
(SELECT MAX(idfichecmd)+1 ,'1' AS idproduit ,'$idC' AS idclt ,'$fb' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'2' AS idproduit ,'$idC' AS idclt ,'$g' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'3' AS idproduit ,'$idC' AS idclt ,'$pi' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'4' AS idproduit ,'$idC' AS idclt ,'$ft' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'5' AS idproduit ,'$idC' AS idclt ,'$sd' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'6' AS idproduit ,'$idC' AS idclt ,'$ad' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'7' AS idproduit ,'$idC' AS idclt ,'$vs' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'8' AS idproduit ,'$idC' AS idclt ,'$wi' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'9' AS idproduit ,'$idC' AS idclt ,'$equip' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'10' AS idproduit ,'$idC' AS idclt ,'$fo' AS qte,'$date' FROM commande),
(SELECT MAX(idfichecmd) ,'11' AS idproduit ,'$idC' AS idclt ,'$fh' AS qte,'$date' FROM commande)")or die(mysql_error());
$result = mysql_query($sql) or die("Unable to add commande : ". mysql_error());
mysql_close();
但是,这个不起作用,有人知道为什么吗?