1. 程式人生 > >Oracle_欄位拼接_逗號_單引號

Oracle_欄位拼接_逗號_單引號

Oracle_欄位拼接逗號單引號

select code,USER_USERID,USER_USERNAME,

('update t_user set userId = ''' || USER_USERID||  ''',userName=''' || USER_USERNAME||  ''' where userCode = ''' ||  code||'''')

from user_info
 where code in ('111','222','333','444')
查詢結果:
code,   USER_USERID,   USER_USERNAME
111     userIdStr      userNameStr

期望拼接效果:
update
t_user set userId= 'userIdStr', userName='userNameStr' where userCode ='111'