本帖最后由 Amy尾巴 于 2017-3-21 11:58 编辑
case when 随便写了个字段选取:
[SQL] 纯文本查看 复制代码 select Distinct CONTEXT from
(
select
case when (字段1 IS not NULL and 字段1 <>'')
then SUBSTRING(字段1 ,8,len(字段1)-7)
when (字段2 IS not NULL and 字段2 <>'')
then SUBSTRING(字段2 ,8,len(字段2 )-7)
end
+ (case when (字段3 IS not NULL and 字段3 <>'') then ','+字段3 else '' end )
as CONTEXT
from 表名
)a
update 根据另一个表的数据更新表字段简单例子
[AppleScript] 纯文本查看 复制代码 update USER_JURISDICTION
set END _TIME =DATEADD(DAY,5000,[USER].USER_REG_TIME)
from [USER]
WHERE USER_JURISDICTION.USER_ID =[USER].USER_ID
AND USER_JURISDICTION.USER_ID ='79951'
|