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 will actually perform the LEFT JOIN behind the scene.

A view once created 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