515318390 by Learn Python & SQL Programming & Arduino Programming

515318390 by Learn Python & SQL Programming & Arduino Programming

Author:Learn Python & SQL Programming & Arduino Programming
Language: eng
Format: epub


Records: 3 Duplicates: 0 Warnings: 0"

DERVIVED TABLES in MySQL Server

A derived table can be defined as virtual table obtained upon execution of a SELECT statements. It is comparable to temp tables, however, in the SELECT statement it is much easier and quicker to use a derived table than a temp table as it would not entail additional steps to create the temp table.

There is often interchangeable use of the term derived table and subquery. When the FROM clause of a SELECT query uses a stand-alone subquery, it is called as a derived table. For example, the syntax below can be used to create a derived table:

SELECT

col_list

FROM

(SELECT

col_list

FROM

tab_1) dervd_tab_nam;

WHERE dervd_tab_nam.d1 > 1;

A derived table is required to have an alias, which can be referenced in future queries, however, there is no such requirement for a subquery. If there is no alias defined for a derived table, the error message below will be displayed by MySQL:

"Every derived table must have its own alias"

Review the example below of a query that will generate Top six products by sales in 2013 from the order and order detail tables in the MySQL server “sample database”:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.