Table of Contents

Views

Views have been introduced in MySQL 5. Views are virtual tables, in that they do not store any data, but rather store a query to dynamically retrieve data from other tables.

Create View

CREATE VIEW viewname AS
SELECT ...

Showing the query of a View

SHOW CREATE VIEW viewname

Example

CREATE VIEW media_usage AS
SELECT media.label AS Media_Label, MAX(scenes.end_min + (scenes.end_sec / 60)) AS Time_Used FROM scenes
LEFT JOIN media ON scenes.media_id = media.media_id
GROUP BY scenes.media_id;