在MySQL中,我們可以建立一個基於另一個現有視圖的視圖。為了讓它理解,我們有一個名為'Info'的視圖,其中包含以下資料-
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)
現在,透過以下查詢,我們正在建立一個名為'info_less'的新視圖,該視圖基於現有視圖'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)
以上是我們如何基於另一個現有視圖建立 MySQL 視圖?的詳細內容。更多資訊請關注PHP中文網其他相關文章!