sqlite

Database; use; embedded relational database

and

英[ənd] 美[ənd , ən,ænd]

conj. And; and, with; so, then; therefore

or

English [ɔ: (r) ] 美[ɔr]

conj. Or; or, or; otherwise, otherwise; left or right

prep.<Ancient, poetry>Before..., earlier than...

n.[Heraldry]Black gold, black

SQLite AND/OR functions syntax

Function: The AND operator allows the existence of multiple conditions in the WHERE clause of a SQL statement. When using the AND operator, the entire condition is true only if all conditions are true. For example, [condition1] AND [condition2] is true only if both condition1 and condition2 are true. The OR operator is also used to combine multiple conditions in the WHERE clause of an SQL statement. When using the OR operator, as long as any one of the conditions is true, the entire condition is true. For example, [condition1] OR [condition2] is true whenever either condition1 or condition2 is true.

Syntax: AND:SELECT column1, column2, columnN FROM table_name WHERE [condition1] AND [condition2]...AND [conditionN];

OR:SELECT column1 , column2, columnN FROM table_name WHERE [condition1] OR [condition2]...OR [conditionN]

SQLite AND/OR functions example

AND实例: 

COMPANY 表

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
下面的 SELECT 语句列出了 AGE 大于等于 25 且工资大于等于 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

OR实例: 
  COMPANY 表
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
下面的 SELECT 语句列出了 AGE 大于等于 25 或工资大于等于 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