“Column count doesn't match value count at row” but it does

前端 未结 7 1729
我在风中等你
我在风中等你 2020-12-30 00:11

I\'ve got a mysql file with over than 14000 statements. All of them are inserts into a table, and when I import the file using console, it throws the following error:

<
7条回答
  •  我在风中等你
    2020-12-30 00:36

    I met the same issue too. @valplo's answer is right. Since I don't have enough reputation to comment, I write it here.

    The correct way to insert multiple values is to list the values after the key word VALUES, not parenthesis around multiple value entries, but parenthesis around single value entries, and separate each single value entry with comma.

    The wrong way is:

    INSERT INTO my_table(column_name_0, column_name_1) VALUES(
        (val_00, val_01),
        (val_10, val_11)
    );
    

    The correct way is:

    INSERT INTO my_table(column_name_0, column_name_1) VALUES
        (val_00, val_01),
        (val_10, val_11);
    

提交回复
热议问题