A distinct way of looking at database data is called a VIEW.

A VIEW is a virtual table of the result set obtained from a MySQL statement (rows and columns of a virtual table can be from one or more database). An advantage of a VIEW is that the change in original table gets reflected in the virtual table. The view does not contain data, but just the rules needed to process data. The views are backed up along with database.

Views are generally used to get data from a database. Consider a table of patients' data. If information such as number of patients who were affected by 'fever' can be generated by view as below:

Syntax

CREATE VIEW 'FEVER' AS SELECT * FROM tblpatients WHERE DISEASE="fever";

SELECT COUNT(*) FROM 'FEVER';

The example above will generate a count of 50.

To check the number of kids in this data we can use another view named 'CHILD':

CREATE VIEW 'CHILD'  AS SELECT * FROM tblpatients WHERE AGE <= 12;

SELECT COUNT(*) FROM 'CHILD';

This example generates a count of let say 40.

Giving a name to the result set helps in easy referencing of data. Hence views are used. Views are defined from MYSQL 5.0.