First things first, before I show you an example, I will tell you the most common types SQL JOINs you can have:
This will return all rows when there is at least one match in both tables.
LEFT JOIN: This will return all rows from the left table, and the matched rows from the right table.
This will return all rows from the right table, and the matched rows from the left table.
This will return all rows when there is a match in at least one of the tables.
The most common type of all the JOINS is the INNER JOIN or a simple join. This is the example I will be showing you more of today.
Now, lets JOIN these two tables with a SQL Select Statement.
Select Customer.ID as CustomerID, Name, OrderID, Date, Amount from Customer
Orders on Orders.CustomerID = Customer.ID;
|The results to this statement will produce the results below.|
Please note, several operators can be used to join tables, such as =, <, >, <>, <=, >=, BETWEEN, LIKE, and NOT, just to name a few. However, the most common operator is the equal symbol.
If you like this post and want to see more, follow me on my website www.chadcompton.com
Or if you prefer...