需求:查询B表数据然后对A表进行更新操作,此处mysql和oracle的语法有区别,特记录如下
TIP
mysql和oracle关于concat函数的操作也不一样,mysql的concat支持多个参数进行拼接,oracle只支持两个参数的拼接,多个参数需要嵌套完成
# mysql
UPDATE sys_category t
INNER JOIN ( SELECT id, NAME FROM sys_category ) c ON c.id = t.pid
SET t.NAME = concat( t.NAME, c.NAME )
WHERE pid = '1183693424827564034'
# oracle
UPDATE JX_QG_EXAMINDEX t
SET t.VNAME = (
SELECT
concat( concat( concat( t.VNAME, '(' ), VNAME ), ')' )
FROM
JX_QG_EXAMINDEX
WHERE
PK_EXAMINDEX = t.PK_PARENT
),
t.PK_PARENT = ( SELECT PK_PARENT FROM JX_QG_EXAMINDEX WHERE PK_EXAMINDEX = t.PK_PARENT )
WHERE
t.PK_PARENT IN ( SELECT PK_EXAMINDEX FROM JX_QG_EXAMINDEX WHERE PK_PARENT = '1001011000000004RFBI' )