
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we create a MySQL view based on another existing view?
In MySQL, we can create a view that is based on another existing view. To make it understand we are having the view ‘Info’ with the following data −
mysql> Create view info AS Select Id, Name, Subject FROM student_info; Query OK, 0 rows affected (0.11 sec) mysql> Select * from Info; +------+---------+------------+ | Id | Name | Subject | +------+---------+------------+ | 101 | YashPal | History | | 105 | Gaurav | Literature | | 125 | Raman | Computers | | NULL | Ram | Computers | +------+---------+------------+ 4 rows in set (0.00 sec)
Now, with the help of the following query we are creating another view names ‘info_less’ that is based on the existing view ‘info’ −
mysql> Create view info_less AS Select Id, Name, Subject FROM info WHERE id >= 120; Query OK, 0 rows affected (0.25 sec) mysql> Select * from info_less; +------+-------+-----------+ | Id | Name | Subject | +------+-------+-----------+ | 125 | Raman | Computers | +------+-------+-----------+ 1 row in set (0.03 sec)
- Related Articles
- How can we modify a MySQL view with CREATE OR REPLACE VIEW statement?
- How can we create MySQL view by selecting data based on pattern matching from base table?
- How can we create a MySQL view with a subquery?
- How can we create a MySQL view with LEFT JOIN?
- How can we create a MySQL view with INNER JOIN?
- How can we create a MySQL view with RIGHT JOIN?
- How can we create a MySQL view with GROUP BY clause?
- How can we create the MySQL view with ORDER BY clause?
- How can we create a MySQL view by using data from multiple tables?
- How can I create a MySQL view that takes the values from a table based on some condition(s)?
- How to create a MySQL view?
- How can we drop a MySQL view from the database?
- Create View Class Based Views Django
- How can we create a MySQL view by selecting some range of values from a base table?
- How do I create a view in MySQL?

Advertisements