我们如何检查 Oracle 数据库中逗号分隔值的列中是否存在字符串

How can we check whether a string is present or not in column with comma separated values in Oracle db

我被困在这个问题上,找不到解决方案。 我有两列 cus_categorycus_flagcus_category 列的值类似于 cus_category

existing,cleared
existing
cleared
expansion,exisitng,cleared
expansion,cleared
former 
former,cleared  
former,cleared,expansion
former,existing,cleared

等等。我想将 cus_flag 设置为 1,其中 cus_category 的值是扩展且存在,即使它类似于 expansion,exisitng,cleared 并将值 0 设置为已清除和前者。如何实现这一点任何人都可以帮助我。

如果类别既有扩展又有现有,那么,

Update [YourTable]
Set cus_flag= Case when (cus_category like '%expansion%' and cus_category like '%existing%') 
then 1 else 0 end

如果类别应该有扩展或现有

 Update  [YourTable]
Set cus_flag= Case when (cus_category like '%expansion%' or cus_category like '%existing%') 
then 1 else 0 end

有 2 个不同的更新

update your_table set cus_flag = 1 
   where cus_category like '%expansion%' and cus_category like '%exisitng%';

update your_table set cus_flag = 0 
   where cus_category like '%cleared%' and cus_category like '%former%';