是否可以基于计数条件(仅使用1条语句)插入表中?
我想做这样的事情:
insert into [table] (...) values (...) if select count(*) from [table] < 5
(仅当表项少于5个时才插入表中)
最佳答案
尝试这样的事情:
insert into [table] (#FIELDS#)
select (#VALUES#) from [table]
where (select count(*) from [table]) < 5
FETCH FIRST ROW ONLY
关于sql - SQL条件插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21696615/