Monthly Archives: December 2011

MySQL Tutorial – Using BETWEEN condition

Using BETWEEN condition

BETWEEN condition is used to retrieve records with in the given range.

The syntax of BETWEEN condition:

SELECT column_name(s)
FROM table_name
Where column_name
BETWEEN value1 AND value2;

MySQL Tutorial – Using the IN function

The IN function can be used to replace the OR condition. It is also used to specify multiple value together with the WHERE clause.

The syntax of IN function:

SELECT column_name(s)
FROM table_name
Where column_name IN (value1,value2,etc…);

MySQL Tutorial – Using HAVING clause

Using HAVING clause

HAVING clause is somewhat similar to WHERE clause and it is used together with the GROUP BY clause. It was added to SQL to combine with the aggregate functions because the WHERE clause doesn’t allow aggregates.

The syntax of HAVING clause:

SELECT column_name, aggregate_function(column_name)
FROM table_name
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;