TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL Inline Views

Overview

In this tutorial, we will learn about MySQL inline views with example. An inline view is a special type of subquery that appears in the FROM clause.

A subquery that creates a derived table that can be used in the FROM clause of a SELECT statement
is called as an inline view.  Inline views are sometimes called  as virtual tables.

Syntax

SELECT…. FROM (subquery) AS  table_alias_name

When a derived table is used in a query, it should be given a table alias We can accomplish this with the AS clause that will act as the table alias.

Example

In the following query, the average of the sums of the population of each continent is determined:

mysql> SELECT *
-> FROM (SELECT Continent, SUM(Population) AS Continent_Population_Sum
-> FROM Country
-> GROUP BY Continent)
-> AS temp
-> ORDER BY Continent;


+—————+————————–+
| Continent | Continent_Population_Sum |
+—————+————————–+
| Asia | 3705025700 |
| Europe | 730074600 |
| North America | 482993000 |
| Africa | 784475000 |
| Oceania | 30401150 |
| Antarctica | 0 |
| South America | 353186400 |
+—————+————————–+
7 rows in set (0.00 sec)

 

MySQL Inline Views

Every table that appears in a FROM clause must have a name, so a subquery in the FROM clause must be
followed by a table alias. The SELECT in the FROM clause is a table subquery. Note that the subqueries in FROM clauses cannot be correlated with the outer query statement.

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

Windows 11 Services Run Prompt

MySQL /

Start MySQL Server on Windows 11

MySQL Community Downloads TDocs

MySQL /

Download & Install MySQL on Windows 11

‹ MySQL ANY Operator› Delete rows in a table using Subquery

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle
  • Draw Parallel Lines using Flowgorithm Graphics

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version