From c3407617c5fcc744721bced015b204765095978a Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Thu, 3 Mar 2022 22:00:01 -0500 Subject: [PATCH] Update for 03-03-22 22:00 --- tech/sql.wiki | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tech/sql.wiki b/tech/sql.wiki index 7ec2a4a..2f2b7b2 100644 --- a/tech/sql.wiki +++ b/tech/sql.wiki @@ -109,6 +109,26 @@ grouping totals based upon some other row. `SELECT Team, COUNT(*) FROM Players GROUP BY Team` +=== JOIN === + +`JOIN` allows two tables to be returned together, where they are 'joined' upon +a shared field. + +{{{ +SELECT Orders.ID, Customers.Name, Orders.Name +FROM Orders +INNER JOIN Customers ON Orders.CustomerId=Customers.Id + }}} + +There are four types of joins +* `INNER JOIN` returns all records that having matching records in both tables +* `LEFT OUTER JOIN` returns all records from the left (Orders in above example) + table, and the matched records from the right table +* `RIGHT OUTER JOIN` returns all records from the right (Customers in above + example) table, and the matched records from the left table +* `FULL OUTER JOIN` returns all records when there is a match in either the + left or right table + == Views == A view can be created with the following command