gpt4 book ai didi

mysql - 在mysql中运行多个SQL命令

转载 作者:行者123 更新时间:2023-11-29 19:29:33 26 4
gpt4 key购买 nike

我尝试用 Delphi 7 编写的代码如下。但我无法在一项操作中运行多个 MySQL 命令。我想要;

A- customer table >>> address_id, customer_id, firstname, lastname,
B- address table >>> address_id, customer_id, firstname, lastname
C- customer table >>> address_id,

B = A and C = B

我需要以.我如何需要 mysql 代码?

modul.Q_Customer.Close;
modul.Q_Customer.SQL.Clear;
modul.Q_Customer.SQL.Add('INSERT INTO customer (customer_group_id,firstname, lastname, email, approved, ip, model, telephone, fax, status, date_added)');
modul.Q_Customer.SQL.Add('Values(:CG, :ADI, :SOYADI, :MAIL, "1", "127.0.0.1", "ISYERI", :TELEFON, :FAX, "1", NOW()); ');

modul.Q_Customer.SQL.Add('INSERT INTO address (customer_id, firstname,lastname,company,VergiDaire, address_1, address_2, city, postcode, country_id, zone_id, VergiNo)');
modul.Q_Customer.SQL.Add('Values(LAST_INSERT_ID(), :ADI, :SOYADI, :FIRMA, :VD, :ADRES1, :ADRES2, :SEMT, :POSTAKOD, "215", :IL, :VN; ');

modul.Q_Customer.SQL.Add('UPDATE customer SET address_id = LAST_INSERT_ID() WHERE customer_id = LAST_INSERT_ID();');

modul.Q_Customer.ParamByName('CG').Value:=CG;
modul.Q_Customer.ParamByName('ADI').Value:=ADI;
modul.Q_Customer.ParamByName('SOYADI').Value:=SOYADI;
modul.Q_Customer.ParamByName('MAIL').Value:=MAIL;
modul.Q_Customer.ParamByName('TELEFON').Value:=TELEFON;
modul.Q_Customer.ParamByName('FAX').Value:=FAX;
modul.Q_Customer.ParamByName('FIRMA').Value:=UNVAN;
modul.Q_Customer.ParamByName('ADRES1').Value:=ADRES1;
modul.Q_Customer.ParamByName('ADRES2').Value:=ADRES2;
modul.Q_Customer.ParamByName('SEMT').Value:=SEMT;
modul.Q_Customer.ParamByName('POSTAKOD').Value:=POSTAKOD;
modul.Q_Customer.ParamByName('IL').Value:=IL;
modul.Q_Customer.ParamByName('VD').Value:=VergiD;
modul.Q_Customer.ParamByName('VN').Value:=VergiN;
modul.Q_Customer.ExecSQL;

最佳答案

我认为你的台词

modul.Q_Customer.SQL.Add('Values(LAST_INSERT_ID(), :ADI, :SOYADI, :FIRMA, :VD, :ADRES1, :ADRES2, :SEMT, :POSTAKOD, "215", :IL, :VN; ');

之后缺少右括号

VN;

顺便说一句,最好尝试使用 MySQl Workbench 工具来识别此类问题。

关于mysql - 在mysql中运行多个SQL命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41895752/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com