{"id":13775,"date":"2023-12-29T01:25:25","date_gmt":"2023-12-29T08:25:25","guid":{"rendered":"https:\/\/www.mysqltutorial.org\/?page_id=13775"},"modified":"2024-01-14T18:59:52","modified_gmt":"2024-01-15T01:59:52","slug":"mysql-left-join","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/","title":{"rendered":"MySQL LEFT JOIN"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn about MySQL <code>LEFT JOIN<\/code> clause and how to use it to retrieve data from two or more related tables.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL LEFT JOIN clause<\/h2>\n\n\n\n<p>The <code>LEFT JOIN<\/code> allows you to retrieve data from two or more tables. Like the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-inner-join\/\">INNER JOIN<\/a><\/code> clause, the <code>LEFT JOIN<\/code> is an optional clause of the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-select-from\/\">SELECT<\/a><\/code> statement, which appears immediately after the <code>FROM<\/code> clause.<\/p>\n\n\n\n<p>The following statement illustrates how to use the <code>LEFT JOIN<\/code> clause to join the two tables, <code>t1<\/code> and <code>t2<\/code>:<\/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    t1\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> t2 <span class=\"hljs-keyword\">ON<\/span> \n    join_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>When you use the <code>LEFT JOIN<\/code> clause, the concepts of the left table (t1) and the right table (t2) come into play within the syntax.<\/p>\n\n\n\n<p>The <code>LEFT JOIN<\/code> clause selects data starting from the left table (<code>t1<\/code>), matching each row from the left table (<code>t1<\/code>) with every corresponding row from the right table(<code>t2<\/code>) based on the <code>join_condition<\/code>.<\/p>\n\n\n\n<p>If the rows from both tables satisfy the join condition, the left join combines columns from both tables into a new row and includes this new row in the result rows.<\/p>\n\n\n\n<p>If a row from the left table (<code>t1<\/code>) does not match with any row from the right table(<code>t2<\/code>), the left join still combines columns of rows from both tables into a new row and includes the new row in the result set. However, it fills in the columns of the row from the right table with the <code>NULL<\/code> values.<\/p>\n\n\n\n<p>In essence, the <code>LEFT JOIN<\/code> returns all rows from the left table, irrespective of whether a matching row from the right table exists or not. <\/p>\n\n\n\n<p>In the absence of a match, the columns of the row from the right table will be filled with <code>NULL<\/code> values.<\/p>\n\n\n\n<p>The following Venn diagram helps you visualize how the <code>LEFT JOIN<\/code> clause works:<\/p>\n\n\n<div class=\"wp-block-image wp-image-1879 size-medium\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"183\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-left-join-Venn-diagram-300x183.png\" alt=\"MySQL LEFT JOIN - Venn Diagram\" class=\"wp-image-1879\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-left-join-Venn-diagram-300x183.png 300w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-left-join-Venn-diagram.png 484w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption class=\"wp-element-caption\">MySQL LEFT JOIN &#8211; Venn Diagram<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">MySQL LEFT JOIN clause examples<\/h2>\n\n\n\n<p>Let&#8217;s take some examples of using the <code>LEFT JOIN<\/code> clause.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1) Using MySQL LEFT JOIN clause to join two tables<\/h3>\n\n\n\n<p>See the following tables <code>customers<\/code> and <code>orders<\/code> 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=\"434\" height=\"304\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/customers-orders.png\" alt=\"\" class=\"wp-image-8036\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/customers-orders.png 434w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/customers-orders-200x140.png 200w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/figure>\n\n\n\n<p>Each customer can have zero or more orders, whereas each order must belong to one customer.<\/p>\n\n\n\n<p>The following query uses the <code>LEFT JOIN<\/code> clause to find all customers and their corresponding orders:<\/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    customers.customerNumber, \n    customerName, \n    orderNumber, \n    <span class=\"hljs-keyword\">status<\/span>\n<span class=\"hljs-keyword\">FROM<\/span>\n    customers\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orders <span class=\"hljs-keyword\">ON<\/span> \n    orders.customerNumber = customers.customerNumber;<\/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>Alternatively, you can make the query shorter using <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-alias\/\">table aliases<\/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-keyword\">SELECT<\/span>\n    c.customerNumber,\n    customerName,\n    orderNumber,\n    <span class=\"hljs-keyword\">status<\/span>\n<span class=\"hljs-keyword\">FROM<\/span>\n    customers c\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orders o \n    <span class=\"hljs-keyword\">ON<\/span> c.customerNumber = o.customerNumber;<\/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<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"394\" height=\"239\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-LEFT-JOIN-example.png\" alt=\"MySQL LEFT JOIN example\" class=\"wp-image-5216\" title=\"MySQL LEFT JOIN example\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-LEFT-JOIN-example.png 394w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-LEFT-JOIN-example-300x182.png 300w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><\/figure>\n\n\n\n<p>In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>customers<\/code> is the left table and <code>orders<\/code> is the right table.<\/li>\n\n\n\n<li>The <code>LEFT JOIN<\/code> clause returns all customers including the customers who have no order. If a customer has no order, the values in the column <code>orderNumber<\/code> and <code>status<\/code> are <code>NULL<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>Since both the <code>customers<\/code> and <code>orders<\/code> tables share the same column name ( <code>customerNumber<\/code>) in the join condition using the equal operator, you can utilize the <code>USING<\/code> syntax 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\tcustomerNumber,\n\tcustomerName,\n\torderNumber,\n\t<span class=\"hljs-keyword\">status<\/span>\n<span class=\"hljs-keyword\">FROM<\/span>\n\tcustomers\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orders <span class=\"hljs-keyword\">USING<\/span> (customerNumber);<\/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 clauses are equivalent:<\/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\">USING (customerNumber)<\/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>And<\/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\">ON c.customerNumber = o.customerNumber<\/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>If you replace the <code>LEFT JOIN<\/code> clause by the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-inner-join\/\">INNER JOIN<\/a><\/code> clause, you will get the only customers who have at least one order.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2) Using MySQL LEFT JOIN clause to find unmatched rows<\/h3>\n\n\n\n<p>The <code>LEFT JOIN<\/code> clause is very useful when you need to identify rows in a table that doesn&#8217;t have a matching row from another table.<\/p>\n\n\n\n<p>The following example uses the <code>LEFT JOIN<\/code> to find customers without any orders:<\/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    c.customerNumber, \n    c.customerName, \n    o.orderNumber, \n    o.status\n<span class=\"hljs-keyword\">FROM<\/span>\n    customers c\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orders o \n    <span class=\"hljs-keyword\">ON<\/span> c.customerNumber = o.customerNumber\n<span class=\"hljs-keyword\">WHERE<\/span>\n    orderNumber <span class=\"hljs-keyword\">IS<\/span> <span class=\"hljs-literal\">NULL<\/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<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"401\" height=\"240\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-LEFT-JOIN-unmatched-rows.png\" alt=\"MySQL LEFT JOIN unmatched rows\" class=\"wp-image-5217\" title=\"MySQL LEFT JOIN unmatched rows\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-LEFT-JOIN-unmatched-rows.png 401w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-LEFT-JOIN-unmatched-rows-300x180.png 300w\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3) Using MySQL LEFT JOIN to join three tables<\/h3>\n\n\n\n<p>See the following three tables <code>employees<\/code>, <code>customers<\/code>, and <code>payments<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"653\" height=\"304\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/payments-customers-employees.png\" alt=\"\" class=\"wp-image-8169\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/payments-customers-employees.png 653w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/payments-customers-employees-200x93.png 200w\" sizes=\"auto, (max-width: 653px) 100vw, 653px\" \/><\/figure>\n\n\n\n<p>This example uses two <code>LEFT JOIN<\/code> clauses to join the three tables: <code>employees<\/code>, <code>customers<\/code>, and <code>payments<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" 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    lastName, \n    firstName, \n    customerName, \n    checkNumber, \n    amount\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> customers <span class=\"hljs-keyword\">ON<\/span> \n    employeeNumber = salesRepEmployeeNumber\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> payments <span class=\"hljs-keyword\">ON<\/span> \n    payments.customerNumber = customers.customerNumber\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> \n    customerName, \n    checkNumber;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><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>This picture shows the partial output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"458\" height=\"379\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/MySQL-LEFT-JOIN-three-tables-example.png\" alt=\"MySQL LEFT JOIN three tables example\" class=\"wp-image-8170\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/MySQL-LEFT-JOIN-three-tables-example.png 458w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/08\/MySQL-LEFT-JOIN-three-tables-example-200x166.png 200w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><\/figure>\n\n\n\n<p>How it works.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first <code>LEFT JOIN<\/code> returns all employees and customers who represented each employee or <code>NULL<\/code> if the employee is not in charge of any customer.<\/li>\n\n\n\n<li>The second <code>LEFT JOIN<\/code> retrieve payments for each customer represented by an employee or returns <code>NULL<\/code> if the customer has no payments.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Condition in WHERE clause vs. ON clause<\/h2>\n\n\n\n<p>The following example uses the <code>LEFT JOIN<\/code> clause to query data from the <code>orders<\/code> and \u00a0<code>orderDetails<\/code> tables:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" 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    o.orderNumber, \n    customerNumber, \n    productCode\n<span class=\"hljs-keyword\">FROM<\/span>\n    orders o\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orderDetails \n    <span class=\"hljs-keyword\">USING<\/span> (orderNumber)\n<span class=\"hljs-keyword\">WHERE<\/span>\n    orderNumber = <span class=\"hljs-number\">10123<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><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 order and its line items of the order number <code>10123<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"292\" height=\"99\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-LEFT-JOIN-Condition-in-WHERE-clause.png\" alt=\"MySQL LEFT JOIN - Condition in WHERE clause\" class=\"wp-image-6263\" title=\"MySQL LEFT JOIN - Condition in WHERE clause\"\/><\/figure>\n\n\n\n<p>However, if you move the condition from the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\">WHERE<\/a><\/code> clause to the <code>ON<\/code> clause:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" 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    o.orderNumber, \n    customerNumber, \n    productCode\n<span class=\"hljs-keyword\">FROM<\/span>\n    orders o\n<span class=\"hljs-keyword\">LEFT<\/span> <span class=\"hljs-keyword\">JOIN<\/span> orderDetails d \n    <span class=\"hljs-keyword\">ON<\/span> o.orderNumber = d.orderNumber <span class=\"hljs-keyword\">AND<\/span> \n       o.orderNumber = <span class=\"hljs-number\">10123<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><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 will have a different meaning.<\/p>\n\n\n\n<p>In this case, the query returns all orders; However, only the order <code>10123<\/code> will have associated line items as shown in the query result:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"294\" height=\"216\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/MySQL-LEFT-JOIN-Condition-in-ON-clause.png\" alt=\"MySQL LEFT JOIN - Condition in ON clause\" class=\"wp-image-6264\" title=\"MySQL LEFT JOIN - Condition in ON clause\"\/><\/figure>\n\n\n\n<p>Notice that for <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-inner-join\/\">INNER JOIN<\/a><\/code> clause, the condition in the <code>ON<\/code> clause is equivalent to the condition in the <code>WHERE<\/code> clause.<\/p>\n\n\n\n<p>In this tutorial, you have learned how to use the MySQL <code>LEFT JOIN<\/code> clause to join data from two or more tables.<\/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=\"13775\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/\"\n\t\t\t\tdata-post-title=\"MySQL LEFT JOIN\"\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=\"13775\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/\"\n\t\t\t\tdata-post-title=\"MySQL LEFT JOIN\"\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 MySQL LEFT JOIN clause and how to use it to retrieve data from two or more related tables.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":174,"menu_order":16,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-13775","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 LEFT JOIN<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn about MySQL LEFT JOIN clause and how to use it to retrieve data from two or more related tables.\" \/>\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-left-join\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL LEFT JOIN\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn about MySQL LEFT JOIN clause and how to use it to retrieve data from two or more related tables.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-15T01:59:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-left-join-Venn-diagram-300x183.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 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-left-join\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-left-join\\\/\",\"name\":\"MySQL LEFT JOIN\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-left-join\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-left-join\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/mysql-left-join-Venn-diagram-300x183.png\",\"datePublished\":\"2023-12-29T08:25:25+00:00\",\"dateModified\":\"2024-01-15T01:59:52+00:00\",\"description\":\"In this tutorial, you will learn about MySQL LEFT JOIN clause and how to use it to retrieve data from two or more related tables.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-left-join\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-left-join\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-left-join\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/mysql-left-join-Venn-diagram.png\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/mysql-left-join-Venn-diagram.png\",\"width\":484,\"height\":295,\"caption\":\"MySQL LEFT JOIN - Venn Diagram\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-left-join\\\/#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 LEFT JOIN\"}]},{\"@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 LEFT JOIN","description":"In this tutorial, you will learn about MySQL LEFT JOIN clause and how to use it to retrieve data from two or more related tables.","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-left-join\/","og_locale":"en_US","og_type":"article","og_title":"MySQL LEFT JOIN","og_description":"In this tutorial, you will learn about MySQL LEFT JOIN clause and how to use it to retrieve data from two or more related tables.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-15T01:59:52+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-left-join-Venn-diagram-300x183.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/","url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/","name":"MySQL LEFT JOIN","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-left-join-Venn-diagram-300x183.png","datePublished":"2023-12-29T08:25:25+00:00","dateModified":"2024-01-15T01:59:52+00:00","description":"In this tutorial, you will learn about MySQL LEFT JOIN clause and how to use it to retrieve data from two or more related tables.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-left-join-Venn-diagram.png","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2011\/05\/mysql-left-join-Venn-diagram.png","width":484,"height":295,"caption":"MySQL LEFT JOIN - Venn Diagram"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-left-join\/#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 LEFT JOIN"}]},{"@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\/13775","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=13775"}],"version-history":[{"count":5,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/13775\/revisions"}],"predecessor-version":[{"id":14572,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/13775\/revisions\/14572"}],"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=13775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}