Oracle:在SQL Server中不起作用的位置更新联接
谁能告诉我,如何为Oracle重写下面的语句(在SQL Server中工作)Oracle:在SQL Server中不起作用的位置更新联接,sql,sql-server,oracle,join,Sql,Sql Server,Oracle,Join,谁能告诉我,如何为Oracle重写下面的语句(在SQL Server中工作) UPDATE ap SET ap.AccessControlID = (SELECT MIN(ID) FROM AccessControl WHERE ClientEntityGroupID = apceg.cliententitygroupid) FROM AccessProfile ap JOIN accessprofile_cegroup apceg ON ap.ID = apceg.accessprofile
UPDATE ap SET ap.AccessControlID = (SELECT MIN(ID) FROM AccessControl WHERE ClientEntityGroupID = apceg.cliententitygroupid)
FROM AccessProfile ap
JOIN accessprofile_cegroup apceg ON ap.ID = apceg.accessprofileid
WHERE ap.AccessControlID IS NULL
上面写着ORA-00933
“SQL命令未正确结束”
AccessProfile可以有0-n个ClientEntityGroup
AccessControl有0-1个ClientEntityGroup
AccessProfile具有0-1 AccessControl
这是一个迁移步骤。之后,我将删除accessprofile_cegroup表,以便:
AccessControl has 0-1 ClientEntityGroup.
AccessProfile has 0-1 AccessControl.
此语句设置每个AccessProfile
的第一个ClientEntityGroup
的AccessControl
,尝试使用合并:
MERGE INTO AccessProfile ap
USING(SELECT apceg.accessprofileid,MIN(ID) as min_id
FROM AccessControl ac
INNER JOIN accessprofile_cegroup apceg
ON(ac.ClientEntityGroupID = apceg.cliententitygroupid)
GROUP BY apceg.accessprofileid) f
ON(f.accessprofileid = ap.ID)
WHEN MATCHED THEN UPDATE SET ap.AccessControlID = f.min_id
WHERE ap.AccessControlID IS NULL
你确实放了一本书;在声明的最后,对吗?你看过我的解决方案了吗?