我的查询完全适用于所有人。我必须清空表格才能更新行 我有一个类似的查询工作完美和更新,但我不知道如何使用vol表的查询进行相同的工作。
查询工作并更新:
@mysql_query("INSERT INTO compagnie (date, nbsvols, tempsvols, totaldistance, totalpassagers, totalcargo, totalfuel, consomoy, rbillets, rcargo, rcollations, totalrecettes, dfuel, dsalaires, dassurances, dtaxes, dpenalites, dmaintenance, dfraisfixes, totaldepenses, budjetinitial, budjetapflotte, benefice, budjet)
VALUES ('$dated','$NrfFlights','$TFT','$TD','$TPC','$TCKG','$Totalfueluse','$Averagefuelconspermn','$TotalTicketsincome','$TotalCargoincome','$Totalcollationtincome','$Totalincome','$Totalfuelcost','$Totalsalary','$Totalinsurancecost','$Totalairporttaxecost','$PenalityPointscost','$Maintenancecost','$Fraisfixescecost','$Totaldepenses','$Initialbudjet','$bugjetapflotte','$Benef','$bugjetact')
ON DUPLICATE KEY UPDATE nbsvols=$NrfFlights, tempsvols=$TFT, totaldistance=$TD, totalpassagers=$TPC, totalcargo=$TCKG, totalfuel=$Totalfueluse, consomoy=$Averagefuelconspermn, rbillets=$TotalTicketsincome, rcargo=$TotalCargoincome, rcollations=$Totalcollationtincome, totalrecettes=$Totalincome, dfuel=$Totalfuelcost, dsalaires=$Totalsalary, dassurances=$Totalinsurancecost, dtaxes=$Totalairporttaxecost, dpenalites=$PenalityPointscost, dmaintenance=$Maintenancecost, dfraisfixes=$Fraisfixescecost, totaldepenses=$Totaldepenses, budjetinitial=$Initialbudjet, budjetapflotte=$bugjetapflotte, benefice=$Benef, budjet=$bugjetact");
查询工作但不更新(我的问题)
@mysql_query("INSERT INTO vol (id, UserName, CompanyName, PilotName, FlightId, FlightDate, rbilletsv, rcargov, rcollationsv, totalrecettesv, dfuelv, dsalairesv, dcrewcostv, dassurancesv, dtaxesv, dpenalitesv, dmaintenancev, totaldepensesv, beneficev)
SELECT id,
UserName,
CompanyName,
PilotName,
FlightId,
FlightDate,
NbrPassengers * $PrixTicket AS rbilletsv,
CargoWeight * $Prixkgcargo AS rcargov,
NbrPassengers * $Prixcollation AS rcollationsv,
NbrPassengers * $PrixTicket + CargoWeight * $Prixkgcargo + NbrPassengers * $Prixcollation AS totalrecettesv,
StartFuelQuantity * $Prixkgfuel - EndFuelQuantity * $Prixkgfuel AS dfuelv,
time_to_sec(TotalBlockTime) * $Prixsalarypilotperh / 3600 AS dsalairesv,
time_to_sec(TotalBlockTime) * $Prixsalarycrewperh / 3600 AS dcrewcostv,
NbrPassengers * $PrixTicket * $Percentinsurance + CargoWeight * $Prixkgcargo * $Percentinsurance + NbrPassengers * $Prixcollation * $Percentinsurance AS dassurancesv,
NbrPassengers * $PrixTicket * $Percentairporttaxe + CargoWeight * $Prixkgcargo * $Percentairporttaxe + NbrPassengers * $Prixcollation * $Percentairporttaxe AS taxesv,
PenalityPoints * $PrixPenalityPointscost AS dpenalitesv,
time_to_sec(TotalBlockTime) * $Prixmaintenancej / 3600,
StartFuelQuantity * $Prixkgfuel - EndFuelQuantity * $Prixkgfuel + time_to_sec(TotalBlockTime) * $Prixsalarypilotperh / 3600 + time_to_sec(TotalBlockTime) * $Prixsalarycrewperh / 3600 + NbrPassengers * $PrixTicket * $Percentinsurance + CargoWeight * $Prixkgcargo * $Percentinsurance + NbrPassengers * $Prixcollation * $Percentinsurance + NbrPassengers * $PrixTicket * $Percentairporttaxe + CargoWeight * $Prixkgcargo * $Percentairporttaxe + NbrPassengers * $Prixcollation * $Percentairporttaxe + PenalityPoints * $PrixPenalityPointscost + time_to_sec(TotalBlockTime) * $Prixmaintenancej / 3600 AS totaldepensesv,
NbrPassengers * $PrixTicket + CargoWeight * $Prixkgcargo + NbrPassengers * $Prixcollation - StartFuelQuantity * $Prixkgfuel + EndFuelQuantity * $Prixkgfuel - time_to_sec(TotalBlockTime) * $Prixsalarypilotperh / 3600 - time_to_sec(TotalBlockTime) * $Prixsalarycrewperh / 3600 - NbrPassengers * $PrixTicket * $Percentinsurance - CargoWeight * $Prixkgcargo * $Percentinsurance - NbrPassengers * $Prixcollation * $Percentinsurance - NbrPassengers * $PrixTicket * $Percentairporttaxe - CargoWeight * $Prixkgcargo * $Percentairporttaxe - NbrPassengers * $Prixcollation * $Percentairporttaxe - PenalityPoints * $PrixPenalityPointscost - time_to_sec(TotalBlockTime) * $Prixmaintenancej / 3600 AS beneficev
FROM flights");