列数与行的值计数不匹配

时间:2015-09-29 11:58:54

标签: mysql sql

INSERT INTO clnt_reports_01 (r_id, cl_no, cl_no, servi, size, vol, 
deliver_point, port_, a_port, road, term, compet, speed, 
rcomments, stage, meetrating, username, user_status, kids, 
hobbies, comments)

VALUES (1, 123123, "test", "test", "test", "test", 
"test", "test", "test", "test", 1, "test", "test",
 3, 5, "test", "test", 5, "test", "test");

获取错误 -

  

错误代码:1136。列数与行

处的值计数不匹配

7 个答案:

答案 0 :(得分:4)

使用'排序字符串,确保在两种情况下都有相同数量的列(20)

INSERT INTO clnt_reports_01 (r_id,cl_no,servi,size,vol,deliver_point,port_,a_port,road,term,compet,speed,rcomments,stage,meetrating,username,user_status,kids,hobbies,comments)

VALUES (1, 123123, 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 1, 'test', 'test', 3, 5, 'test', 'test', 5, 'test', 'test');

"被视为标识符(列名)。

还可以更好地使用INSERT ... SELECT来提高可读性:

INSERT INTO clnt_reports_01 (
  r_id,
  cl_no,
  servi,
  size,
  vol,
  deliver_point,
  port_,
  a_port,
  road,
  term,
  compet,
  speed,
  rcomments,
  stage,
  meetrating,
  username,
  user_status,
  kids,
  hobbies,
  comments)
SELECT
  1       AS r_id,
 123123   AS cl_no,
 'test'   AS servi,
 'test'   AS size,
 'test'   As vol, 
 'test'   AS deliver_point,
 'test'   AS port_,
 'test'   AS a_port,
 'test'   AS road,
 'test'   AS term,
  1       AS compet,
 'test'   AS speed,
 'test'   AS rcomments,
  3       AS stage,
  5       AS meetrating,
 'test'   AS username,
 'test'   AS user_status,
  5       AS kids,
 'test'   AS hobbies,
 'test'   AS comments;

答案 1 :(得分:2)

修改

您指定了21列,但只提供了20个值,因此存在不匹配。

cl_no似乎重复了两次。删除它。

您需要使用单引号而不是文本的双引号

INSERT INTO clnt_reports_01 ( 
r_id,
cl_no,
servi,
size,
vol,
deliver_point,
port_,
a_port,
road,
term,
compet,
speed,
rcomments,
stage,
meetrating,
username,
user_status,
kids,
hobbies,
comments)

VALUES (1, 
123123, 
'test', 
'test', 
'test', 
'test', 
'test', 
'test', 
'test', 
'test', 
1, 
'test', 
'test', 
3, 
5,
'test', 
'test', 
5, 
'test', 
'test');

答案 2 :(得分:2)

插入查询以指定21列并传递值20。

答案 3 :(得分:1)

您为21列提供了20个值,可能是因为您已将列<div summernote class="summernote" ng-model="postData.content" placeholder="Content"></div> 列出两次。即使您修复了列/值计数问题,也会出现此错误

  

错误代码:1136

     

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

答案 4 :(得分:0)

嗯,您的列数(21)与您的值数(20)不匹配,您试图将20个内容插入21列....

这是由错误

给出的
  

错误代码:1136。列数与行

处的值计数不匹配

答案 5 :(得分:0)

对于这个问题:

  

错误代码:1136。列数与行

处的值计数不匹配

cl_no使用了两次,删除了一列。

您可以使用单引号而不是双引号。

如:

"test" -> 'test'

答案 6 :(得分:0)

INSERT INTO fgm_pastor(
matriculePastor,
pastorName,
pastorSurname,
pastorBirthdayDate,
birthdayPlace,
pastorFathername,
pastorMothername,
pastorSexe,
pastorPhone,
pastorEmail,
dateConversion,
workBeforeBibleSchool,
rankProbation,
areaOfCalling,
nberYearArea,
nbreYearDistrict,
martialSituation,
nationality,
pastorAdresse,
photoProfil,
raisonIndispoMissionnaire,
id) 
VALUES
(
'matriculetest3',
'nom test',
'prenomtest',
'2013-09-12',
'Dagobert',
'mon pere resr' ,
'ma mere test',
'M',
'phone test',
'pastorEmail test',
'2018-12-28',
'infomaticien',
'rank test',
'area test',
1,
3,
'Single test',
'Cameroun test',
'adresse test',
'phototest'
'RAS',
4
);