Creating and using views
You can create and use views on any hosting.com server that uses MySQL.Setting up a test database
To demonstrate a basic example using views, let’s start by creating a database for testing purposes. In the following SQL statement, replace username with your account username:You can run the previous SQL command (and the following SQL commands) from the command line using the mysql program or in your web browser using phpMyAdmin.
Creating the view
Now that we have a database and a table to work with, we are ready to create a simple view. Let’s create a view named minimumPriceView. This view returns a data set of all products whose cost is greater than 1.00 (in dollars, Euros, or whatever currency unit we’re working with). To create this view, run the following MySQL statement:If you look at a list of the tables in the database, you will see the minimumPriceView view listed alongside the other tables. Remember, however, that views are virtual tables containing queries. They do not contain any actual data.
Using the view
You can now use the minimumPriceView view in a query:- For more information about MySQL views, please visit http://dev.mysql.com/doc/refman/5.0/en/views.html.
- For more information about the CREATE VIEW statement, please visit http://dev.mysql.com/doc/refman/5.0/en/create-view.html.