SQLite and OR administrators are utilized to assemble various conditions to limit the chose information in a SQLite explanation. These two administrators are called conjunctive administrators.
These administrators give a way to make various correlations with various administrators in a similar SQLite articulation.
The AND Operator
The AND administrator permits the presence of different conditions in a SQLite proclamation's WHERE proviso. While utilizing AND administrator, complete condition will be expected genuine when all the conditions are valid. For instance, [condition1] AND [condition2] will be genuine just when both condition1 and condition2 are valid.
Syntax
Following is the fundamental punctuation of AND administrator with WHERE proviso.
SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] AND [condition2]...AND [conditionN];
You can join N number of conditions utilizing AND administrator. For a move to be made by the SQLite articulation, regardless of whether it be an exchange or question, all conditions isolated by the AND should be TRUE.
Example
Consider COMPANY table with the accompanying records −
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 Paul 32 California 20000.0
2 Allen 25 Texas 15000.0
3 Teddy 23 Norway 20000.0
4 Mark 25 Rich-Mond 65000.0
5 David 27 Texas 85000.0
6 Kim 22 South-Hall 45000.0
7 James 24 Houston 10000.0
Following SELECT articulation records down all the records where AGE is more noteworthy than or equivalent to 25 AND compensation is more prominent than or equivalent to 65000.00.
sqlite> SELECT * FROM COMPANY WHERE AGE >= 25 AND SALARY >= 65000;
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
4 Mark 25 Rich-Mond 65000.0
5 David 27 Texas 85000.0
The OR Operator
The OR administrator is additionally used to join various conditions in a SQLite articulation's WHERE proviso. While utilizing OR administrator, complete condition will be accepted genuine when in any event any of the conditions is valid. For instance, [condition1] OR [condition2] will be valid if either condition1 or condition2 is valid.
Syntax
Following is the essential language structure of OR administrator with WHERE provision.
SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] OR [condition2]...OR [conditionN]
You can consolidate N number of conditions utilizing OR administrator. For a move to be made by the SQLite articulation, regardless of whether it be an exchange or question, just any of the conditions isolated by the OR should be TRUE.
Example
Consider COMPANY table with the accompanying records.
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 Paul 32 California 20000.0
2 Allen 25 Texas 15000.0
3 Teddy 23 Norway 20000.0
4 Mark 25 Rich-Mond 65000.0
5 David 27 Texas 85000.0
6 Kim 22 South-Hall 45000.0
7 James 24 Houston 10000.0
Following SELECT proclamation records down all the records where AGE is more noteworthy than or equivalent to 25 OR compensation is more prominent than or equivalent to 65000.00.
sqlite> SELECT * FROM COMPANY WHERE AGE >= 25 OR SALARY >= 65000;
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 Paul 32 California 20000.0
2 Allen 25 Texas 15000.0
4 Mark 25 Rich-Mond 65000.0
5 David 27 Texas 85000.0