我有问题,如果行不存在,我想在表中插入字段
我的代码是:
INSERT INTO `myTable` (
`circuit` ,
`date` ,
`session` ,
`lap` ,
`time`
) SELECT 'misano', '2013-10-11', 1, 1, '0:01:06:332'
FROM `myTable`
WHERE NOT EXISTS (SELECT 1 FROM `myTable` WHERE `circuit` = 'misano' AND `date` = '2013-10-11' AND `session` = 1 AND `lap` = 1 AND `time` = '0:01:06:332')
如果在“myTable”中至少有一行,则此代码可以正常工作。如果“myTable”为空,SQL 返回:0 行。