IF('111' IS NOT NULL){
IF(strV = 「1」 )
{  
strV  LIKE  SUBSTR( strV ,1,1) +’%’ 

ELSE IF(strV = 「1」 )

strV  LIKE  SUBSTR(strV ,1,1) +’%’ 

}以上这段逻辑,写在sql的where部分,怎么写,我试着写了一下,碰到两个问题:第一、case '111' when is not null....或者case '111' when not null都会说is not null语法不对。第二、SUBSTR('111',1,1) +’%’ 这样他不认识百分号,应该怎么写哪位高手帮我完整的翻译一下,谢谢

解决方案 »

  1.   

    楼主oracle的版本是9i以上的吗??
    8i不支持case when。
      

  2.   

    如果楼主写的是WHERE子句的过滤条件,那么用函数decode()应该能解决楼主的问题,希望楼主用自然语言表达一下自己的想法,你写的东西 ,看不明白,呵呵
      

  3.   

    1、如果不支持CASE ... WHEN ... 用DECODE()2、SUBSTR('111',1,1) || '%'
      

  4.   

    strV like DECODE('111',NULL,strV,DECODE(strV,1,SUBSTR(strV,1,1)||'%',NULL))
      

  5.   

    在where子句里用or
    比如select 1 from dual where ('123' is null and 1=1) or ('123' is not null and 1<>1)
      

  6.   

    1.case when '111' is not null then '0' end
    2.SUBSTR('111',1,1) || '%'