Your Ad Here
SQL Basic

Bookmark and Share
SQL AND

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:

CityAverageTemperatureTemperatureUnitDate
Chennai26 Celcius 11/21/2008
Bombay27 Celcius 11/10/2008
Calcutta30 Celcius 11/25/2008
Bangalore18 Celcius 10/09/2008
Delhi28 Celcius 12/29/2008
Kochin17 Celcius 12/19/2008
 
Example 1:

Executed Query:
SELECT *
FROM temperature_information
WHERE AverageTemperature > 20 AND AverageTemperature < 28

Result:
CityAverageTemperatureTemperatureUnitDate
Chennai26 Celcius 11/21/2008
Bombay27 Celcius 11/10/2008

Description:
it shows the temperature details which is AverageTemperature above than 20 and below than 28.
 
Example 2:

Executed Query:
SELECT *
FROM temperature_information
WHERE AverageTemperature = 26 AND AverageTemperature < 20

Result:
CityAverageTemperatureTemperatureUnitDate
Chennai26 Celcius 11/21/2008
Bangalore18 Celcius 10/09/2008
Kochin17 Celcius 12/19/2008

Description:
it shows the temperature details which is AverageTemperature equals 26 and below than 20.
 
Example 3:

Executed Query:
SELECT *
FROM temperature_information
WHERE AverageTemperature = 26 OR AverageTemperature = 27

Result:
CityAverageTemperatureTemperatureUnitDate
Chennai26 Celcius 11/21/2008
Bombay27 Celcius 11/10/2008

Description:
it shows the temperature details which is AverageTemperature equals 26 or equals 27 also both.

Today's Deal