Retrieving Data Through a View
Creating a view displays nothing. All that CREATE VIEW does is cause the DBMS to save the view as a named SELECT statement. To see data through a view, query the view by using SELECT, just as you would query a table. You can:
Rearrange the order of the displayed columns with the SELECT clause
Use operators and functions to perform calculations
Change column headings with AS
Filter rows with WHERE
Group rows with GROUP BY
Filtered grouped rows with HAVING
Join the view to other views or tables with JOIN
Sort the result with ORDER BY
To retrieve data through a view:
- Type:
view is ...
SELECT columns FROM view [JOIN joins] [WHERE search_condition] [GROUP BY group_columns] [HAVING search_condition] [ORDER BY sort_columns];
Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.