简体   繁体   中英

How to insert into column in mysql?

I have four column named Name, Date, Items and Amount . I want to insert many Items and that's amount at same name and same date. How to do that?

You can put more rows into database by this way:

INSERT INTO table (name, date, items, amount) VALUES
('name1', '2015-05-10', 'items here', 1),
('name2', '2015-05-10', 'items here', 5),
('name3', '2015-05-10', 'items here', 3),
('name4', '2015-05-10', 'items here', 9),
('name5', '2015-05-10', 'items here', 1)

The SQL query should be prepeared with using for or foreach loop, if you have array of items.

INSERT INTO table_name (name, date, items, amount) VALUES ('name1', '2020-11-10', 'items here', 1), ('name2', '2020-11-10', 'items here ', 5), ('name3', '2020-11-10', 'items here', 3), ('name4', '2020-11-10', 'items here', 9), ('name5 ', '2020-11-10', '这里的项目', 1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM