A view from two tables

suggest change

A view is most useful when it can be used to pull in data from more than one table.

CREATE VIEW myview AS
SELECT a.*, b.extra_data FROM main_table a 
LEFT OUTER JOIN other_table b 
ON a.id = b.id;

In MySQL, views are not materialized. If you now perform the simple query SELECT * FROM myview, MySQL performs the LEFT JOIN behind the scenes.

Once created, a view can be joined to other views or tables.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents