avatar
left join and inner join Javascript

» First and foremost, let us create two tables named `Customers` and `Orders` in order to practice using Left Join and Inner Join.

Customers Table:

Orders Table:

» Use INNER JOIN to retrieve rows where the `CustomerID` matches in both the Customers and Orders tables. Records that do not meet this criterion will be excluded from the result set.

SELECT Customers.CustomerName, Orders.Product
FROM Customers
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

Result:

» Use LEFT JOIN to include all rows from the Customers table, along with matching rows from the Orders table based on the CustomerID. Records from the Customers table will be retained even if there is no corresponding match in the Orders table.

SELECT Customers.CustomerName, Orders.Product
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

Result:

24
show mysql databases pick database mysql show tables mysql update table mysql
You need to login to do this manipulation!