{"id":214,"date":"2011-05-07T09:51:59","date_gmt":"2011-05-07T09:51:59","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=214"},"modified":"2024-06-09T21:03:44","modified_gmt":"2024-06-10T04:03:44","slug":"mysql-having","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/","title":{"rendered":"MySQL HAVING"},"content":{"rendered":"\n<p><strong>Summary<\/strong><em>: <\/em>in this tutorial, you will learn how to use MySQL <code>HAVING<\/code> clause to specify a filter condition for groups of rows or aggregates.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL HAVING clause<\/h2>\n\n\n\n<p>The <code>HAVING<\/code> clause is used with the <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-group-by\/\">GROUP BY<\/a> clause to filter the groups based on a specified condition.<\/p>\n\n\n\n<p>The <code>HAVING<\/code> clause allows you to apply a condition to the groups returned by the <code>GROUP BY<\/code> clause and only include groups that meet the specified condition.<\/p>\n\n\n\n<p>Here&#8217;s the syntax of the <code>HAVING<\/code> clause:<\/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    table_name\n<span class=\"hljs-keyword\">WHERE<\/span> \n    search_condition\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> \n    group_by_expression\n<span class=\"hljs-keyword\">HAVING<\/span> \n    group_condition;<\/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<p>In this syntax, you specify a condition in the <code>HAVING<\/code> clause. <\/p>\n\n\n\n<p>The <code>HAVING<\/code> clause evaluates each group returned by the <code>GROUP BY<\/code> clause. If the result is true (1), it includes the group in the result set.<\/p>\n\n\n\n<p>The <code>HAVING<\/code> clause applies the condition to groups of rows, while the <code>WHERE<\/code> clause applies the condition to individual rows<\/p>\n\n\n\n<p>If you omit the <code>GROUP BY<\/code> clause, the <code>HAVING<\/code> clause behaves like the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\">WHERE<\/a><\/code>&nbsp;clause.<\/p>\n\n\n\n<p>MySQL evaluates the <code>HAVING<\/code> clause after the <code>FROM<\/code>, <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\">WHERE<\/a><\/code>, <code>SELECT<\/code> and <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-group-by\/\">GROUP BY<\/a><\/code> clauses, but before <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-distinct\/\">DISTINCT<\/a><\/code>, <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-select\/\">SELECT<\/a><\/code>, <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-order-by\/\">ORDER BY<\/a><\/code>, and <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-limit\/\">LIMIT<\/a><\/code> clauses:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2024\/06\/MySQL-HAVING.svg\" alt=\"MySQL HAVING\" class=\"wp-image-14658\"\/><\/figure>\n\n\n\n<p>Note that the SQL standard specifies that the&nbsp;<code>HAVING<\/code>&nbsp;is evaluated before&nbsp;<code>SELECT<\/code>&nbsp;clause and after&nbsp;<code>GROUP BY<\/code>&nbsp;clause.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL HAVING clause examples<\/h2>\n\n\n\n<p>Let&#8217;s take some examples of using the <code>HAVING<\/code> clause to understand how it works. <\/p>\n\n\n\n<p>We&#8217;ll use the <code>orderdetails<\/code> table in the <a title=\"MySQL Sample Database\" href=\"https:\/\/www.mysqltutorial.org\/getting-started-with-mysql\/mysql-sample-database\/\">sample database<\/a> for the demonstration.<\/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\/orderdetails.svg\" alt=\"\" class=\"wp-image-10768\"\/><\/figure>\n\n\n\n<p>The following uses the <code>GROUP BY<\/code> clause to get order numbers, the number of items sold per order, and total sales for each from the <code>orderdetails<\/code> table:<\/p>\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  ordernumber, \n  <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered) <span class=\"hljs-keyword\">AS<\/span> itemsCount, \n  <span class=\"hljs-keyword\">SUM<\/span>(priceeach * quantityOrdered) <span class=\"hljs-keyword\">AS<\/span> total \n<span class=\"hljs-keyword\">FROM<\/span> \n  orderdetails \n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> \n  ordernumber;<\/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<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-having\/#1\">Try It Out<\/a><\/p>\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-comment\">-------------+------------+----------+<\/span>\n| ordernumber | itemsCount | total    |\n+<span class=\"hljs-comment\">-------------+------------+----------+<\/span>\n|       10100 |        151 | 10223.83 |\n|       10101 |        142 | 10549.01 |\n|       10102 |         80 |  5494.78 |\n|       10103 |        541 | 50218.95 |\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>Now, you can find which order has total sales greater than <code>1000<\/code> by using the <code>HAVING<\/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  ordernumber, \n  <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered) <span class=\"hljs-keyword\">AS<\/span> itemsCount, \n  <span class=\"hljs-keyword\">SUM<\/span>(priceeach * quantityOrdered) <span class=\"hljs-keyword\">AS<\/span> total \n<span class=\"hljs-keyword\">FROM<\/span> \n  orderdetails \n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> \n  ordernumber \n<span class=\"hljs-keyword\">HAVING<\/span> \n  total &gt; <span class=\"hljs-number\">1000<\/span>;<\/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><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-having\/#2\">Try It Out<\/a><\/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-comment\">-------------+------------+----------+<\/span>\n| ordernumber | itemsCount | total    |\n+<span class=\"hljs-comment\">-------------+------------+----------+<\/span>\n|       10100 |        151 | 10223.83 |\n|       10101 |        142 | 10549.01 |\n|       10102 |         80 |  5494.78 |\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>It&#8217;s possible to form a complex condition in the <code>HAVING<\/code> clause using logical operators such as <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-or\/\">OR<\/a><\/code> and <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-and\/\">AND<\/a><\/code>.<\/p>\n\n\n\n<p>The following example uses the <code>HAVING<\/code> clause to find orders that have total amounts greater than <code>1000<\/code> and contain more than <code>600<\/code> items:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" 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    ordernumber,\n    <span class=\"hljs-keyword\">SUM<\/span>(quantityOrdered) <span class=\"hljs-keyword\">AS<\/span> itemsCount,\n    <span class=\"hljs-keyword\">SUM<\/span>(priceeach*quantityOrdered) <span class=\"hljs-keyword\">AS<\/span> total\n<span class=\"hljs-keyword\">FROM<\/span>\n    orderdetails\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span> ordernumber\n<span class=\"hljs-keyword\">HAVING<\/span> \n    total &gt; <span class=\"hljs-number\">1000<\/span> <span class=\"hljs-keyword\">AND<\/span> \n    itemsCount &gt; <span class=\"hljs-number\">600<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><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><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-having\/#3\">Try It Out<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"232\" height=\"195\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-HAVING-complex-condition.png\" alt=\"\" class=\"wp-image-6340\"\/><\/figure>\n\n\n\n<p>Suppose that you want to find all orders that already shipped and have a total amount greater than 1500, you can <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-join\/\">join<\/a> the <code>orderdetails<\/code> table with the <code>orders<\/code> table using the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-inner-join\/\">INNER JOIN<\/a><\/code> clause and apply a condition on&nbsp;<code>status<\/code> column and <code>total<\/code> aggregate as shown in the following query:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" 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    a.ordernumber, \n    <span class=\"hljs-keyword\">status<\/span>, \n    <span class=\"hljs-keyword\">SUM<\/span>(priceeach*quantityOrdered) total\n<span class=\"hljs-keyword\">FROM<\/span>\n    orderdetails a\n<span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orders b \n    <span class=\"hljs-keyword\">ON<\/span> b.ordernumber = a.ordernumber\n<span class=\"hljs-keyword\">GROUP<\/span> <span class=\"hljs-keyword\">BY<\/span>  \n    ordernumber, \n    <span class=\"hljs-keyword\">status<\/span>\n<span class=\"hljs-keyword\">HAVING<\/span> \n    <span class=\"hljs-keyword\">status<\/span> = <span class=\"hljs-string\">'Shipped'<\/span> <span class=\"hljs-keyword\">AND<\/span> \n    total &gt; <span class=\"hljs-number\">1500<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><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><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-having\/#4\">Try It Out<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"219\" height=\"164\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-HAVING-with-INNER-JOIN-example.png\" alt=\"MySQL HAVING with INNER JOIN example\" class=\"wp-image-6341\" title=\"MySQL HAVING with INNER JOIN example\"\/><\/figure>\n\n\n\n<p>The <code>HAVING<\/code> clause is only useful when you use it with the <code>GROUP BY<\/code> clause to generate the output of the high-level reports. <\/p>\n\n\n\n<p>For example, you can use the <code>HAVING<\/code> clause to answer questions like finding the number of orders this month, this quarter, or this year that have a total amount greater than 10K.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the MySQL <code>HAVING<\/code> clause with the <code>GROUP BY<\/code> clause to specify a filter condition for groups of rows or aggregates.<\/li>\n<\/ul>\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=\"214\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/\"\n\t\t\t\tdata-post-title=\"MySQL HAVING\"\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=\"214\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/\"\n\t\t\t\tdata-post-title=\"MySQL HAVING\"\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 how to use MySQL HAVING clause to specify a filter condition for groups of rows or aggregates.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":174,"menu_order":21,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-214","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 HAVING<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to use MySQL HAVING clause to specify a filter condition for groups of rows or aggregates.\" \/>\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-having\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL HAVING\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to use MySQL HAVING clause to specify a filter condition for groups of rows or aggregates.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-10T04:03:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2024\/06\/MySQL-HAVING.svg\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 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-having\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-having\\\/\",\"name\":\"MySQL HAVING\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-having\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-having\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/MySQL-HAVING.svg\",\"datePublished\":\"2011-05-07T09:51:59+00:00\",\"dateModified\":\"2024-06-10T04:03:44+00:00\",\"description\":\"In this tutorial, you will learn how to use MySQL HAVING clause to specify a filter condition for groups of rows or aggregates.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-having\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-having\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-having\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/MySQL-HAVING.svg\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/MySQL-HAVING.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-having\\\/#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 HAVING\"}]},{\"@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 HAVING","description":"In this tutorial, you will learn how to use MySQL HAVING clause to specify a filter condition for groups of rows or aggregates.","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-having\/","og_locale":"en_US","og_type":"article","og_title":"MySQL HAVING","og_description":"In this tutorial, you will learn how to use MySQL HAVING clause to specify a filter condition for groups of rows or aggregates.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-06-10T04:03:44+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2024\/06\/MySQL-HAVING.svg","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/","url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/","name":"MySQL HAVING","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2024\/06\/MySQL-HAVING.svg","datePublished":"2011-05-07T09:51:59+00:00","dateModified":"2024-06-10T04:03:44+00:00","description":"In this tutorial, you will learn how to use MySQL HAVING clause to specify a filter condition for groups of rows or aggregates.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2024\/06\/MySQL-HAVING.svg","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2024\/06\/MySQL-HAVING.svg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-having\/#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 HAVING"}]},{"@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\/214","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=214"}],"version-history":[{"count":5,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/214\/revisions"}],"predecessor-version":[{"id":14661,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/214\/revisions\/14661"}],"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=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}