AND is a Keyword comes follow by Where statement using combine two conditions in single query. The query will give the result which is match for that two conditions.
SQL OR
OR is a Keyword comes follow by Where statement using combine two conditions in single query. The query will give the result which is match for any one of the condition or both.
Let us assume that we have the following table it shows the temperature information about the cities in india. Table name is temperature_information:
| City | AverageTemperature | TemperatureUnit | Date |
| Chennai | 26 | Celcius | 11/21/2008 |
| Bombay | 27 | Celcius | 11/10/2008 |
| Calcutta | 30 | Celcius | 11/25/2008 |
| Bangalore | 18 | Celcius | 10/09/2008 |
| Delhi | 28 | Celcius | 12/29/2008 |
| Kochin | 17 | Celcius | 12/19/2008 |
Executed Query:
SELECT * FROM temperature_information WHERE AverageTemperature > 20 AND AverageTemperature < 28
Result:
| City | AverageTemperature | TemperatureUnit | Date |
| Chennai | 26 | Celcius | 11/21/2008 |
| Bombay | 27 | Celcius | 11/10/2008 |
Description:
it shows the temperature details which is AverageTemperature above than 20 and below than 28.
Executed Query:
SELECT * FROM temperature_information WHERE AverageTemperature = 26 AND AverageTemperature < 20
Result:
| City | AverageTemperature | TemperatureUnit | Date |
| Chennai | 26 | Celcius | 11/21/2008 |
| Bangalore | 18 | Celcius | 10/09/2008 |
| Kochin | 17 | Celcius | 12/19/2008 |
Description:
it shows the temperature details which is AverageTemperature equals 26 and below than 20.
Executed Query:
SELECT * FROM temperature_information WHERE AverageTemperature = 26 OR AverageTemperature = 27
Result:
| City | AverageTemperature | TemperatureUnit | Date |
| Chennai | 26 | Celcius | 11/21/2008 |
| Bombay | 27 | Celcius | 11/10/2008 |
Description:
it shows the temperature details which is AverageTemperature equals 26 or equals 27 also both.