在这个问题之后,我一直在尝试模仿正确的答案,仅当表格为空时才在表格中插入数据。
这是我的代码:
INSERT INTO `statuses` SELECT
('Something', 'Something else', 123),
('Something', 'Something else', 234)
WHERE NOT EXISTS (SELECT * FROM `statuses`);
但是,如果表为空,我不会添加元素,而是得到:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE NOT EXISTS (SELECT * FROM `statuses`)'
我应该如何编写查询以便仅在表为空时才插入值?