SQL AND OR

AND and OR operators are used to filter results with 2 conditions.

The AND operator displays the results when the 2 conditions are met.

Condition1 AND condition2

The OR operator displays the results where either of the 2 conditions.

Condition1 OR condition2

In the table people

namesurnamenickname
HARRYCLARKWHITE
HARRYSMITHBENITO
WILLIAMJONESCLARK

The following statement (eg AND) give the following result:

SELECT * FROM people WHERE name = 'HARRY' AND surname = 'Smith'

namesurnamenickname
HARRYSMITHBENITO

The following statement (eg OR) give the following result:

People SELECT * FROM WHERE name = 'HARRY' OR surname = 'Smith'

namesurnamenickname
HARRYCLARKWHITE
HARRYSMITHBENITO

You can also combine AND and OR, as the following example:

SELECT * FROM people WHERE name = 'HARRY' AND (surname = 'Smith' OR surname = 'JONES)

namesurnamenickname
HARRYSMITHBENITO