迟到的答案
如果您使用的是 SQLITE 3.7.11或更高版本,则可以通过这种语法插入多行,
最简单的方法
INSERT INTO Rating (rID, mID, stars, ratingDate) VALUES ('207', '102', '5', null) , ('207', '102', '5', null) , ('207', '102', '5', null)
如果使用新的 SQLITE 版本,上面发布的有问题的子句确实有效。
选择条款
insert into Rating
SELECT '207' AS rID, '101' AS mID, '5' AS stars, null AS ratingDate
UNION SELECT '207', '102', '5', null
UNION SELECT '207', '103', '5', null
UNION SELECT '207', '104', '5', null
UNION SELECT '207', '105', '5', null
UNION SELECT '207', '106', '5', null
UNION SELECT '207', '107', '5', null
UNION SELECT '207', '108', '5', null
或 SQL 是
insert into Rating (rID, mID, stars, ratingDate)
SELECT '207', '101', '5', null
UNION SELECT '207', '102', '5', null
UNION SELECT '207', '103', '5', null
UNION SELECT '207', '104', '5', null
UNION SELECT '207', '105', '5', null
UNION SELECT '207', '106', '5', null
UNION SELECT '207', '107', '5', null
UNION SELECT '207', '108', '5', null
请记住,我不想检查上述插入值集中的重复项,然后使用它来UNION ALL
代替,UNION
因为它会快一点。