Skip to content
  • AI
  • Github

Scratch that

Bite sized bits

  • AI
  • Github
  • ⤫
snow covered mountains

Left join – SQL

Posted by Posted on
0

In SQL, a LEFT JOIN (also called a LEFT OUTER JOIN) is a way to combine data from two or more tables based on a related column between them. It returns all rows from the left table, and any matching rows from the right table. If there is no match, NULL values are returned for right table’s columns.

Here is the syntax for a LEFT JOIN in SQL:

Copy Code Copied Use a different Browser

SELECT column1, column2, ...
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;

Here’s an example that joins the “customers” and “orders” tables on the “customer_id” column:

Copy Code Copied Use a different Browser

SELECT customers.name, orders.order_date
FROM customers
LEFT JOIN orders
ON customers.customer_id = orders.customer_id;

This will return all rows from the “customers” table, along with any matching rows from the “orders” table. If a customer has no orders, NULL values will be returned for the “orders.order_date” column.

Categories: Algorithms

Post navigation

Previous Previous post: Quick Sort Vs. Merge Sort
ladies, women, talking
Next Next post: Right Join – SQL
  • Algorithms
  • Front-end
  • Javascript
  • Philosophy
  • Project Management
  • Psychology
  • Science
  • Technology
  • Uncategorized
Copyright © 2025 - Scratch that // By - Deepak Anandrao