Skip to content

Latest commit

 

History

History

00_creating_views

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Creating Views in MySQL

Overview

To create a view in MySQL, you can use the CREATE VIEW statement followed by the view name and the SELECT query that defines the view's data.

Example:

CREATE VIEW sales_by_client AS 
SELECT 
c.client_id,
c.name,
SUM(invoice_total) AS total_sales
FROM clients c
JOIN invoices i USING(client_id)
GROUP BY client_id, name;