Home  >  Article  >  Database  >  What is the usage of not in oracle

What is the usage of not in oracle

WBOY
WBOYOriginal
2022-01-21 10:35:014740browse

In Oracle, not is used to negate the specified condition. When the specified condition is true, the result of not is false. When the specified condition is false, the result of not is true. The syntax is: "Select where not conditional expression".

What is the usage of not in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

What is the usage of not in Oracle

Oracle’s logical operators are also indispensable factors used in SQL statements. There are three

logical operator meanings

  • and Double value operator, if both left and right conditions are true, the obtained value is true

  • or Double value operation operator, as long as one of the left and right conditions is true, the obtained value will be true

  • not single-reference operator, also known as the negation operator, NOT is usually a unary operation symbol, that is, only the right side of NOT can contain an expression, which inverts the result. If the expression result is True, then the result of NOT is False; otherwise, if the result of the expression is False, then the result of NOT is True.

Oracle's logical operators are also used in SQL language to give some examples:

Select * from emp where sal > 2000 and job = ‘SALESMAN';

Look for employees whose salary is higher than 2,000 and whose position is sales.

Select * from emp where job = ‘CLERK' or deptno = 20;

Find the list of employees whose job is CLERK or whose department number is 20

Select * from emp where not (sal > 3000 or sal < 1500);

Find those employees whose salary is neither greater than 3000 nor less than 1500, that is, in the range of 1500 to 3000 , equivalent to: select * from emp where sal between 1500 and 3000;

Combined with the various operators listed above, here is a summary of the priority sentences of all operators in Oracle that are essential Factors, there are three

operator levels

  • arithmetic operators (i.e. ' ','-','*','/') 1

  • Connection operators (i.e. '||') 2

  • Comparison operators (i.e. '>', '>=', '') 3

Usually use '()' to change the priority of the operator.

It should be noted that the priority of and is better than or, that is to say, the following statement

Select * from emp where sal < 1500 or sal >= 2000 and job = ‘ANALYST&#39;;

is equivalent to

Select * from emp where sal < 1500 or (sal >= 2000 and job = ‘ANALYST&#39;);

rather than the ## you expected. #

Select * from emp where (sal < 1500 or sal >= 2000) and job = ‘ANALYST&#39;;

Generally, even if we want to express the meaning of the first statement, in order to avoid misunderstanding, we do not use the first way of writing, but use brackets to indicate that we need to calculate the following parts first.

Recommended tutorial: "

Oracle Tutorial"

The above is the detailed content of What is the usage of not in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn