问题
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