lower等函数位置不同引起的后遗症

刚找出了一个bug,大家来看下面几条SQL:

建立测试环境
1、create table temp_email(fid number(10),femail varchar2(50));

2、insert into table temp_email values(1,'3266988@qq.com');
    insert into table temp_email values(1,'3266988@QQ.com');
    insert into table temp_email values(1,'3266988@qq.COM');
    insert into table temp_email values(1,'2558418@163.com');
    insert into table temp_email values(1,'2545459@qq.com');

执行如下2条SQL:
测试1:
   select femail 
    from
    (select lower(femail) femail from temp_email 
     where femail not like '%@qq.com'
     )a 
    where a.femail like '%@qq.com'



测试2:
   select femail 
    from
    (select femail from temp_email 
     where lower(femail) not like '%@qq.com'
     )a 
    where a.femail like '%@qq.com'

结论:函数的位置不要乱用,在此的实例显示了若有大小写的数据,就会造成不必要的麻烦!


发表评论

电子邮件地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>