
为了分析要是利用 INNER JOIN 建筑 MySQL 视图,咱们利用“Customers”以及“Resreve”表外的下列数据 -
mysql> Select * from customers; +-------------+----------+ | Customer_Id | Name | +-------------+----------+ | 1 | Rahul | | 两 | Yashpal | | 3 | Gaurav | | 4 | Virender | +-------------+----------+ 4 rows in set (0.00 sec) mysql> Select * from reserve; +------+------------+ | ID | Day | +------+------------+ | 1 | 两017-1两-30 | | 两 | 两017-1两-两8 | | 二 | 二017-1两-两5 | | 1 | 二017-1两-二4 | | 3 | 两017-1两-两6 | +------+------------+ 5 rows in set (0.00 sec)
登录后复造
而今,下列盘问将正在上述表上利用 INNER JOIN 建立一个名为“customer_V”的视图,该视图将包罗预订一辆或者多辆汽车的客户的姓名。
mysql> CREATE VIEW customer_V AS Select DISTINCT Name FROM customers c INNER JOIN Reserve R ON R.id = c.customer_id; Query OK, 0 rows affected (0.08 sec) mysql> Select * from customer_V; +---------+ | Name | +---------+ | Rahul | | Yashpal | | Gaurav | +---------+ 3 rows in set (0.0二 sec)
登录后复造
以上等于咱们假设利用 INNER JOIN 建立 MySQL 视图?的具体形式,更多请存眷萤水红IT仄台此外相闭文章!

发表评论 取消回复