How do I create a view in MySQL?
By default, a new view is created in the default database. To create the view explicitly in a given database, use db_name. view_name syntax to qualify the view name with the database name: CREATE VIEW test.
To create a view, a user must have the appropriate system privilege according to the specific implementation. CREATE VIEW view_name AS SELECT column1, column2..... FROM table_name WHERE [condition]; You can include multiple tables in your SELECT statement in a similar way as you use them in a normal SQL SELECT query.
The syntax for the CREATE VIEW statement in MySQL is: CREATE [OR REPLACE] VIEW view_name AS SELECT columns FROM tables [WHERE conditions]; OR REPLACE. Optional.
http://dev.mysql.com/doc/refman/5.5/en/create-view.html
Example:
Create View `MyViewName` as Select col1, col2, col3 From myTable T
CREATE VIEW v AS SELECT * FROM t;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With