MySQL: Multiple Inserts for a single column

前端 未结 2 683
刺人心
刺人心 2021-02-05 21:13

I\'m looking for a way to do multiple row inserts when I\'m only inserting data for a single column.

Here is the example table:

+-------+-------------+--         


        
相关标签:
2条回答
  • 2021-02-05 21:20

    I will advise you Don't put multiple values in a column. make a new table:

         INSERT INTO table_name (id, name) VALUES (1, 'name1'), (1, 'name2'), (1, 'name3'), (1, 'name4');
    
    0 讨论(0)
  • 2021-02-05 21:34

    your syntax is a bit off. put parentheses around each data "set" (meaning a single value in this case) that you are trying to insert.

    INSERT INTO User_Roll(name) VALUES ('admin'), ('author'), ('mod'), ('user'), ('guest');
    
    0 讨论(0)
提交回复
热议问题