{"id":5964,"date":"2017-07-04T08:07:31","date_gmt":"2017-07-04T15:07:31","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=5964"},"modified":"2024-01-04T07:04:10","modified_gmt":"2024-01-04T14:04:10","slug":"mysql-derived-table","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/","title":{"rendered":"MySQL Derived Tables"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn about MySQL derived tables and how to use them to simplify complex queries.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL derived tables<\/h2>\n\n\n\n<p>A derived table is a virtual table returned from a <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-select-from\/\">SELECT<\/a><\/code> statement. A derived table is similar to a <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-temporary-table\/\">temporary table<\/a>, but using a derived table in the <code>SELECT<\/code> statement is much simpler than a temporary table because it does not require creating a temporary table.<\/p>\n\n\n\n<p>The term derived table and <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-subquery\/\">subquery<\/a> is often used interchangeably. When a stand-alone subquery is used in the <code>FROM<\/code> clause of a <code>SELECT<\/code> statement, it is also called a derived table.<\/p>\n\n\n\n<p>The following illustrates a query that uses a derived table:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"659\" height=\"232\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table.png\" alt=\"MySQL Derived Table\" class=\"wp-image-5965\" title=\"MySQL Derived Table\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table.png 659w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table-300x106.png 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/figure>\n\n\n\n<p class=\"note\">Note that a stand-alone subquery is a subquery that can execute independently of the outer query.<\/p>\n\n\n\n<p>Unlike a subquery, a derived table must have an <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-alias\/\">alias<\/a> so that you can reference its name later in the query. If a derived table does not have an alias, MySQL will issue the following error:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Every derived table must have its own alias.<\/code><\/span><\/pre>\n\n\n<p>The following illustrates the syntax of a query that uses a derived table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    select_list\n<span class=\"hljs-keyword\">FROM<\/span>\n    (<span class=\"hljs-keyword\">SELECT<\/span> \n        select_list\n    <span class=\"hljs-keyword\">FROM<\/span>\n        table_1) derived_table_name\n<span class=\"hljs-keyword\">WHERE<\/span> \n    derived_table_name.c1 &gt; <span class=\"hljs-number\">0<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Basic MySQL Derived Table example<\/h2>\n\n\n\n<p>The following query gets the top five products by sales revenue in 2003 from the <code>orders<\/code> and <code>orderdetails<\/code> tables in the <a href=\"https:\/\/www.mysqltutorial.org\/getting-started-with-mysql\/mysql-sample-database\/\">sample database<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"444\" height=\"194\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/orders_order_details_tables.png\" alt=\"Orders and OrderDetails Tables\" class=\"wp-image-3827\" title=\"Orders and OrderDetails Tables\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/orders_order_details_tables.png 444w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/orders_order_details_tables-300x131.png 300w\" sizes=\"auto, (max-width: 444px) 100vw, 444px\" \/><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    productCode, \n    <span class=\"hljs-keyword\">ROUND<\/span>(<span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach)) sales\n<span class=\"hljs-keyword\">FROM<\/span>\n    orderdetails\n        <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span>\n    orders <span class=\"hljs-keyword\">USING<\/span> (orderNumber)\n<span class=\"hljs-keyword\">WHERE<\/span>\n    <span class=\"hljs-keyword\">YEAR<\/span>(shippedDate) = <span class=\"hljs-number\">2003<\/span>\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> productCode\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> sales <span class=\"hljs-keyword\">DESC<\/span>\n<span class=\"hljs-keyword\">LIMIT<\/span> <span class=\"hljs-number\">5<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"169\" height=\"118\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table-Example-1.png\" alt=\"MySQL Derived Table Example 1\" class=\"wp-image-5984\" title=\"MySQL Derived Table Example 1\"\/><\/figure>\n\n\n\n<p>You can use the result of this query as a derived table and join it with the <code>products<\/code> table as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2023\/10\/products.svg\" alt=\"\" class=\"wp-image-10788\"\/><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    productName, sales\n<span class=\"hljs-keyword\">FROM<\/span>\n    (<span class=\"hljs-keyword\">SELECT<\/span> \n        productCode, \n        <span class=\"hljs-keyword\">ROUND<\/span>(<span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach)) sales\n    <span class=\"hljs-keyword\">FROM<\/span>\n        orderdetails\n    <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orders <span class=\"hljs-keyword\">USING<\/span> (orderNumber)\n    <span class=\"hljs-keyword\">WHERE<\/span>\n        <span class=\"hljs-keyword\">YEAR<\/span>(shippedDate) = <span class=\"hljs-number\">2003<\/span>\n    <span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> productCode\n    <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> sales <span class=\"hljs-keyword\">DESC<\/span>\n    <span class=\"hljs-keyword\">LIMIT<\/span> <span class=\"hljs-number\">5<\/span>) top5products2003\n<span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span>\n    products <span class=\"hljs-keyword\">USING<\/span> (productCode);\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following shows the output of the query above:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"245\" height=\"117\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table-Top-5-Products-2013.png\" alt=\"MySQL Derived Table - Top 5 Products 2013\" class=\"wp-image-5985\" title=\"MySQL Derived Table - Top 5 Products 2013\"\/><\/figure>\n\n\n\n<p>In this example:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>First, the subquery is executed to create a result set or derived table.<\/li>\n\n\n\n<li>Then, the outer query is executed that joins the <code>top5product2003<\/code> derived table with the <code>products<\/code> table using the <code>productCode<\/code> column.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">A more complex MySQL Derived Table example<\/h2>\n\n\n\n<p>Suppose you have to classify the customers who bought products in 2003 into 3 groups: <code>platinum<\/code>, <code>gold<\/code>, and <code>silver<\/code>. And you need to know the number of customers in each group with the following conditions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Platinum customers who have orders with a volume greater than 100K.<\/li>\n\n\n\n<li>Gold customers who have orders with a volume between 10K and 100K.<\/li>\n\n\n\n<li>Silver customers who have orders with a volume of less than 10K.<\/li>\n<\/ul>\n\n\n\n<p>To form this query, you first need to put each customer into the respective group using <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-control-flow-functions\/mysql-case-function\/\">CASE<\/a><\/code> expression and <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-group-by\/\">GROUP BY<\/a><\/code> clause as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    customerNumber,\n    <span class=\"hljs-keyword\">ROUND<\/span>(<span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach)) sales,\n    (<span class=\"hljs-keyword\">CASE<\/span>\n        <span class=\"hljs-keyword\">WHEN<\/span> <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach) &lt; <span class=\"hljs-number\">10000<\/span> <span class=\"hljs-keyword\">THEN<\/span> <span class=\"hljs-string\">'Silver'<\/span>\n        <span class=\"hljs-keyword\">WHEN<\/span> <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach) <span class=\"hljs-keyword\">BETWEEN<\/span> <span class=\"hljs-number\">10000<\/span> <span class=\"hljs-keyword\">AND<\/span> <span class=\"hljs-number\">100000<\/span> <span class=\"hljs-keyword\">THEN<\/span> <span class=\"hljs-string\">'Gold'<\/span>\n        <span class=\"hljs-keyword\">WHEN<\/span> <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach) &gt; <span class=\"hljs-number\">100000<\/span> <span class=\"hljs-keyword\">THEN<\/span> <span class=\"hljs-string\">'Platinum'<\/span>\n    <span class=\"hljs-keyword\">END<\/span>) customerGroup\n<span class=\"hljs-keyword\">FROM<\/span>\n    orderdetails\n        <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span>\n    orders <span class=\"hljs-keyword\">USING<\/span> (orderNumber)\n<span class=\"hljs-keyword\">WHERE<\/span>\n    <span class=\"hljs-keyword\">YEAR<\/span>(shippedDate) = <span class=\"hljs-number\">2003<\/span>\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> customerNumber;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following is the output of the query:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"281\" height=\"197\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table-Customer-Groups.png\" alt=\"MySQL Derived Table - Customer Groups\" class=\"wp-image-5986\" title=\"MySQL Derived Table - Customer Groups\"\/><\/figure>\n\n\n\n<p>Then, you can use this query as the derived table and perform grouping as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    customerGroup, \n    <span class=\"hljs-keyword\">COUNT<\/span>(cg.customerGroup) <span class=\"hljs-keyword\">AS<\/span> groupCount\n<span class=\"hljs-keyword\">FROM<\/span>\n    (<span class=\"hljs-keyword\">SELECT<\/span> \n        customerNumber,\n            <span class=\"hljs-keyword\">ROUND<\/span>(<span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach)) sales,\n            (<span class=\"hljs-keyword\">CASE<\/span>\n                <span class=\"hljs-keyword\">WHEN<\/span> <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach) &lt; <span class=\"hljs-number\">10000<\/span> <span class=\"hljs-keyword\">THEN<\/span> <span class=\"hljs-string\">'Silver'<\/span>\n                <span class=\"hljs-keyword\">WHEN<\/span> <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach) <span class=\"hljs-keyword\">BETWEEN<\/span> <span class=\"hljs-number\">10000<\/span> <span class=\"hljs-keyword\">AND<\/span> <span class=\"hljs-number\">100000<\/span> <span class=\"hljs-keyword\">THEN<\/span> <span class=\"hljs-string\">'Gold'<\/span>\n                <span class=\"hljs-keyword\">WHEN<\/span> <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered * priceEach) &gt; <span class=\"hljs-number\">100000<\/span> <span class=\"hljs-keyword\">THEN<\/span> <span class=\"hljs-string\">'Platinum'<\/span>\n            <span class=\"hljs-keyword\">END<\/span>) customerGroup\n    <span class=\"hljs-keyword\">FROM<\/span>\n        orderdetails\n    <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orders <span class=\"hljs-keyword\">USING<\/span> (orderNumber)\n    <span class=\"hljs-keyword\">WHERE<\/span>\n        <span class=\"hljs-keyword\">YEAR<\/span>(shippedDate) = <span class=\"hljs-number\">2003<\/span>\n    <span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> customerNumber) cg\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> cg.customerGroup;    \n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The query returns the customer groups and the number of customers in each.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"185\" height=\"81\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table-Customer-Group-Counts.png\" alt=\"MySQL Derived Table - Customer Group Counts\" class=\"wp-image-5987\" title=\"MySQL Derived Table - Customer Group Counts\"\/><\/figure>\n\n\n\n<p>In this tutorial, you have learned how to use MySQL Derived Tables which are subqueries in the <code>FROM<\/code> clause to simplify complex queries.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"5964\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/\"\n\t\t\t\tdata-post-title=\"MySQL Derived Tables\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"5964\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/\"\n\t\t\t\tdata-post-title=\"MySQL Derived Tables\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn about the MySQL derived table and how to it to simplify complex queries.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":174,"menu_order":25,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5964","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL Derived Tables<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn about MySQL derived tables and how to use them to simplify complex queries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL Derived Tables\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn about MySQL derived tables and how to use them to simplify complex queries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-04T14:04:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-derived-table\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-derived-table\\\/\",\"name\":\"MySQL Derived Tables\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-derived-table\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-derived-table\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/MySQL-Derived-Table.png\",\"datePublished\":\"2017-07-04T15:07:31+00:00\",\"dateModified\":\"2024-01-04T14:04:10+00:00\",\"description\":\"In this tutorial, you will learn about MySQL derived tables and how to use them to simplify complex queries.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-derived-table\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-derived-table\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-derived-table\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/MySQL-Derived-Table.png\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/MySQL-Derived-Table.png\",\"width\":659,\"height\":232,\"caption\":\"MySQL Derived Table\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-derived-table\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Basics\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL Derived Tables\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL Derived Tables","description":"In this tutorial, you will learn about MySQL derived tables and how to use them to simplify complex queries.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/","og_locale":"en_US","og_type":"article","og_title":"MySQL Derived Tables","og_description":"In this tutorial, you will learn about MySQL derived tables and how to use them to simplify complex queries.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-04T14:04:10+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/","url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/","name":"MySQL Derived Tables","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table.png","datePublished":"2017-07-04T15:07:31+00:00","dateModified":"2024-01-04T14:04:10+00:00","description":"In this tutorial, you will learn about MySQL derived tables and how to use them to simplify complex queries.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table.png","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2017\/07\/MySQL-Derived-Table.png","width":659,"height":232,"caption":"MySQL Derived Table"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-derived-table\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Basics","item":"https:\/\/www.mysqltutorial.org\/mysql-basics\/"},{"@type":"ListItem","position":3,"name":"MySQL Derived Tables"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/5964","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=5964"}],"version-history":[{"count":5,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/5964\/revisions"}],"predecessor-version":[{"id":14197,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/5964\/revisions\/14197"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/174"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=5964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}