多条纪录的插入利用select 子句insert into titles(...) select ... from table1 -----这条语句包含你要插入的批量数据如果你只是单独的纪录 只能写多条掉纪录的插入,即把你的改为:INSERT INTO titles (title_id, title, type, pub_id, price) VALUES ('BU9876', 'Creating Web Pages', 'business', '1389', '29.99'), INSERT INTO titles (title_id, title, type, pub_id, price) VALUES ('BU9877', 'Creating Web Pages', 'business', '1389', '29.99'), INSERT INTO titles (title_id, title, type, pub_id, price) VALUES ('BU9878', 'Creating Web Pages', 'business', '1389', '29.99'), INSERT INTO titles (title_id, title, type, pub_id, price) VALUES ('BU9879', 'Creating Web Pages', 'business', '1389', '29.99')
不过可以用select插入若干行从另一个表里选择数据插入这个表
INSERT INTO titles (title_id, title, type, pub_id, price) select 'BU9876', 'Creating Web Pages', 'business', '1389', '29.99' union all select 'BU9877', 'Creating Web Pages', 'business', '1389', '29.99' union all select 'BU9878', 'Creating Web Pages', 'business', '1389', '29.99' union all select 'BU9879', 'Creating Web Pages', 'business', '1389', '29.99'
select ... from table1 -----这条语句包含你要插入的批量数据如果你只是单独的纪录
只能写多条掉纪录的插入,即把你的改为:INSERT INTO titles
(title_id, title, type, pub_id, price)
VALUES ('BU9876', 'Creating Web Pages', 'business', '1389', '29.99'),
INSERT INTO titles
(title_id, title, type, pub_id, price)
VALUES ('BU9877', 'Creating Web Pages', 'business', '1389', '29.99'),
INSERT INTO titles
(title_id, title, type, pub_id, price)
VALUES ('BU9878', 'Creating Web Pages', 'business', '1389', '29.99'),
INSERT INTO titles
(title_id, title, type, pub_id, price)
VALUES ('BU9879', 'Creating Web Pages', 'business', '1389', '29.99')
(title_id, title, type, pub_id, price)
select 'BU9876', 'Creating Web Pages', 'business', '1389', '29.99' union all
select 'BU9877', 'Creating Web Pages', 'business', '1389', '29.99' union all
select 'BU9878', 'Creating Web Pages', 'business', '1389', '29.99' union all
select 'BU9879', 'Creating Web Pages', 'business', '1389', '29.99'