O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:
    SELECT columns
      FROM view
      [JOIN joins]
      [WHERE search_condition]
      [GROUP BY group_columns]
      [HAVING search_condition]
      [ORDER BY sort_columns];
    
    view is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required