Wednesday, May 29, 2013

sql:mysql:insert multiple rows into table:ERROR 1136 (21S01) at line 15: Column count doesn't match value count at row 1

To insert multiple rows into a table at one go, use the following syntax -

Example:

INSERT INTO numericTypeDesc    (cTypeName,     iType,     cDescription)
                                          values     ("tenure",           30,          "One month"),
                                                         ("tenure",           90,          "Three months"),
                                                         ("tenure",           360,        "One year");

Do not enclose the rows within a parent set of braces, as would be the normal tendency, like -
INSERT INTO numericTypeDesc    (cTypeName,     iType,     cDescription)
                                          values     (
                                                         ("tenure",           30,          "One month"),
                                                         ("tenure",           90,          "Three months"),
                                                         ("tenure",          360,         "One year")
                                                         );

No comments:

Post a Comment