列数与第1.1行的值计数不匹配

时间:2013-04-19 00:17:11

标签: sql

当我尝试插入此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);

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分: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);