gpt4 book ai didi

mysql - 列数与值数不匹配

转载 作者:太空宇宙 更新时间:2023-11-03 12:15:28 27 4
gpt4 key购买 nike

谁能看出为什么这个 SQL 字符串会抛出“列数与值数不匹配”错误?

    SQL = ("INSERT INTO partners_customers(account_name,address1,city,postcode,parent_partners_acc,parent_partners_id) _
VALUES ('" & newcustname.Text & "','" & newcustaddress.Text & "','" & newcustcity.Text & "," & newcustpostcode.Text & "," & Home.activeuser & "," & Home.activeuserid & "'); SELECT LAST_INSERT_ID()")

据我所知,它有 6 列和 6 个值。

这让我发疯:(

谢谢!

最佳答案

在最后 3 个值上,您缺少单引号。格式化代码可以帮助您找到这些类型的问题:

SQL = ("
INSERT INTO partners_customers (
account_name,
address1,
city,
postcode,
parent_partners_acc,
parent_partners_id
) _
VALUES
(
'" & newcustname. TEXT & "',
'" & newcustaddress. TEXT & "',
'" & newcustcity. TEXT & "',
'" & newcustpostcode. TEXT & "',
'" & Home.activeuser & "',
'" & Home.activeuserid & "'
);

SELECT
LAST_INSERT_ID()
");

关于mysql - 列数与值数不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22427933/

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