1

当我尝试插入此 SQL 语句时,我收到一条错误消息,指出列计数与第 1 行的值计数不匹配。

INSERT INTO APPLICANT (fullName, Email, CompanyName, Phone, Fax, GovernmentEmployee, Academic, InternationalAttendee, SpeakerOrPresenter, FirstTimeAttendee)

VALUES
('$fullName','$Email','$CompanyName','$Telephone','$Fax', $GovernmentEmployee, $Academic, $InternationalAttendee, $Speaker, $Presenter, $FirstTimeAttendee);
4

2 回答 2

1

您尝试插入列 : SpeakerOrPresenter
两个不同的值:$Speaker$Presenter

因此,要插入的值比接收数据的列要多。

您可以更改您的查询,使其看起来像这样(其中 SpeakerOrPresenter 列分为 2 个不同的列):

INSERT INTO APPLICANT (fullName, Email, CompanyName, Phone, Fax, GovernmentEmployee, Academic, InternationalAttendee, Speaker, Presenter, FirstTimeAttendee)
VALUES
('$fullName','$Email','$CompanyName','$Telephone','$Fax', $GovernmentEmployee, $Academic, $InternationalAttendee, $Speaker, $Presenter, $FirstTimeAttendee);

或者像这样(将扬声器和演示者这两个值合并为一个):

INSERT INTO APPLICANT (fullName, Email, CompanyName, Phone, Fax, GovernmentEmployee, Academic, InternationalAttendee, SpeakerOrPresenter, FirstTimeAttendee)
VALUES
('$fullName','$Email','$CompanyName','$Telephone','$Fax', $GovernmentEmployee, $Academic, $InternationalAttendee, $SpeakerOrPresenter, $FirstTimeAttendee);
于 2013-04-19T00:20:10.110 回答
1

在 INSERT 子句中列出了 10 个列,在 VALUES 子句中列出了 11 个值。每个子句中的编号必须相同。您有 a$Speaker和 a $Presenterfor 值,但只有一SpeakerOrPresenter列似乎适用于两者。

于 2013-04-19T00:19:05.383 回答