Alternate in access database [duplicate]

梦想与她 提交于 2019-12-24 16:35:11

问题


I want to check whether a row exists or not before inserting a new one in Access 2007.
I have the following working query in SQL Server but I'm having trouble converting it to Access.

update category set name='hell' where categoryid=287
if @@rowcount=0
begin
insert into category(categoryid,name,path,parentcategoryid,creationdate) values (287,'a','a',12,'')
end

回答1:


Try this

update category set name='hell' where categoryid=287;

if not exists(select * from Category where categoryid=287)
    insert into category(categoryid,name,path,parentcategoryid,creationdate) 
values (287,'a','a',12,'');


来源:https://stackoverflow.com/questions/32295708/alternate-in-access-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!