为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:dm8
【操作系统】:麒麟v7
【CPU】:x86
【问题描述】*:
THEN 子句想要处理 WHERE 后面的条件。
举例:
select * from tableName where
case type
when 0
then name = 'aaa' and 其他条件
when 1
then name = 'bbb' and 其他条件
when 2
then name = 'ccc' and 其他条件
else 1 = 1 end
写一个存储过程
可以改写语句:
select * from tableName where
(case
when 0
then name = ‘aaa’ and 其他条件
when 1
then name = ‘bbb’ and 其他条件
when 2
then name = ‘ccc’ and 其他条件
else 1 = 1 end ) = 1;
麻烦把表结构、数据和结果贴一下