大家好,我想知道每个查询一次可以使用1个以上的INSERT吗?还是每次必须一次完成一次INSERT?

例如,我想将这两个查询作为一个查询来执行以节省服务器资源:

INSERT INTO ExtraStats (date, supportStaff, startEmails, endEmails, emailsAnswered) VALUES ('2012-09-01', '5', '4', '3', '2') ON DUPLICATE KEY UPDATE supportStaff = '5', startEmails = '4', endEmails = '3', emailsAnswered = '2'
INSERT INTO ExtraStats (date, supportStaff, startEmails, endEmails, emailsAnswered) VALUES ('2012-09-2', '5', '6', '7', '8') ON DUPLICATE KEY UPDATE supportStaff = '5', startEmails = '6', endEmails = '7', emailsAnswered = '8'


是否有将它们结合在一起的方法?我试着只是将它们放在同一查询中,但它不喜欢它。

最佳答案

INSERT INTO ExtraStats (date, supportStaff, startEmails, endEmails, emailsAnswered)
VALUES ('2012-09-01', '5', '4', '3', '2')
ON DUPLICATE KEY UPDATE supportStaff = '5', startEmails = '4', endEmails = '3', emailsAnswered = '2';

('2012-09-2', '5', '6', '7', '8')
ON DUPLICATE KEY UPDATE supportStaff = '5', startEmails = '6', endEmails = '7', emailsAnswered = '8'

10-04 13:50