Oracle is not equal to the number. oracle is equal to the number.

Source: Internet
Author: User

Oracle is not equal to the number. oracle is equal to the number.

In Oracle, non-equal signs can be used in the following ways:
<> ,! =, ^ =

 

Test SQL

create table test(  id int,  name varchar2(10),  age int)insert into test(id,name,age) values(1,'zhangsan',23);insert into test(id,name,age) values(2,'lisi','');insert into test(id,name,age) values(3,'wangwu',null);insert into test(id,name,age) values(4,'sunqi',27);insert into test(id,name,age) values(5,'',22);

Both the field NAME and AGE have null values.

 

Example 1: query data whose AGE is not 23

select * from test where  age <> 23;

 

Example 2: query data whose NAME is not lisi

select * from test where name != 'lisi';


 

The above two examples strictly do not meet our requirements because null values are not queried.

Null can only be determined by is null or is not null. Other operators and null operations are both false.

 

The correct SQL statement is:

Select * from test where instr (concat (name, 'xx'), 'lisi') = 0; -- query records whose name field is not equal to 'lisi' or select * from test where nvl (name, 'xx') <> 'lisi ';
Select * from test where instr (concat (age, 00), 23) = 0; -- query records whose age field is not 23 or select * from test where nvl (age, 00) <> 23;


Author: itmyhome


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.