zoukankan      html  css  js  c++  java
  • Oracle中奇怪的【不等于号】

    Oracle中奇怪的【不等于号】

     
     

    在Oracle中,不等号有三种:<>,!=,^= 

      例如:

      select * from test where name<>'xn'。返回的结果是name不为xn,且name不空的记录。但是这与我们想要得到的结果有出入,因为我们的目的是得到name为xn的全部记录,当然这也包括name为空的记录,所以这些写SQL语句是有问题的。为了解决这个问题,我们可以采用以下两种方案:

    select * from test where instr(concat(name,'xx'),'xn') = 0 ;
    
    select * from test where nvl(name,'xx')<>'xn' ;

      备注:null只能通过is null或者is not null来判断,其它操作符与null操作都是false。

      各数据库中的字符串连接方法

      1)MySQL:CONCAT()

      2)Oracle:CONCAT(),||

      3)SQL Server: +

    例如:

    SELECT 'this is '+'a test';                         返回值this a test
    
    SELECT CONCAT('this is ','a test') from dual;   返回值this a test
    
    SELECT 'this is '||'a test' from dual;           返回值this a test
     
    分类: ORACLE
  • 相关阅读:
    struts2 DMI
    MFC添加背景图片
    c++ 副本构造器
    climits
    Qt中的qreal
    Http概述(一)
    重构学习-重构原则
    QDir的mkdir和mkpath区别
    Qt学习笔记网络(一)
    Qt5 新特性
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/5622971.html
Copyright © 2011-2022 走看看