我们如何在给定的mysql查询中选择记录: 当var1喜欢value1或var2喜欢value2然后'有效'其他'无效'来自xx作为s
时,请帮助我选择带有大小写的查询select
case
when SUBSTRING(Trim(Pan_No), 4, 1) ='C'
and (z.tds_Vendor_Type_Lookup_Code not like '%COMP%' or Vendor_Name not like '%Pvt%' or Vendor_Name not like '%Ldt%' or Vendor_Name not like '%Limited%' or Vendor_Name not like '%Private%' )
then 'InValid Pan 4th Character for a Company' end as code
from xyz as a
在此查询中始终运行其他条件请指导我一个有效的方法。
答案 0 :(得分:2)
您错过了案例的end
声明,此外您还可以添加else
内容
select
case
when SUBSTRING(Trim(Pan_No), 4, 1) ='C'
and (
z.tds_Vendor_Type_Lookup_Code not like '%COMP%'
or Vendor_Name not like '%Pvt%'
or Vendor_Name not like '%Ldt%'
or Vendor_Name not like '%Limited%'
or Vendor_Name not like '%Private%'
)
then 'InValid Pan 4th Character for a Company'
else 'Valid' end as validity
from xyz