Home >Database >Oracle >What is the difference between and and or in oracle?

What is the difference between and and or in oracle?

WBOY
WBOYOriginal
2022-01-25 11:57:266805browse

Difference: 1. When used for filtering conditions, and means "and", and it must return true when all conditions are true, while or means "or", as long as one condition is true. will return true; 2. The priority of and is greater than or.

What is the difference between and and or in oracle?

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

What is the difference between and and or in Oracle

1.and means intersection

2.or means union

3.The priority ratio of and or high

(FirstName='Thomas' OR FirstName='William') AND LastName='Carter' 会得到 lastname 必须为 carter ,firstname 为 thomas  或者 william的人 
 thomas   carter
 william    carter
FirstName='Thomas' OR FirstName='William'  AND LastName='Carter' 可以得到 william carter 或者 firstname 为ithomas lastname 不一定是 carter的人 比如:
 thomas   carter
 william    carter
 thomas   king

is a matter of the order of or and and. The priority of and is higher than that of or. a or b and c calculate the results of b and c first and then calculate a.

and has priority greater than or.

If parentheses are added, or will be executed first and then and will be executed; without parentheses, and will be executed first and then or, so the query results are different. Example:

Database existing data:

Thomas Carter

William Carter

Thomas King

Execution:

SELECT * FROM Persons WHERE (FirstName='Thomas' OR FirstName='William')
  AND LastName='Carter'

The result is:

Thomas Carter

William Carter

Execution:

SELECT * FROM Persons WHERE FirstName='Thomas' OR FirstName='William'
  AND LastName='Carter'

The result is:

Thomas Carter

 William Carter

 Thomas King

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of What is the difference between and and or 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