Created
January 28, 2011 04:12
-
-
Save nathanbrauer/799820 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql> select * from `Customer` c JOIN (`Order` o) on (c.CustomerID=o.CustomerID) order by c.CustomerID; | |
| +------------+-----------+---------+------------+-----------+ | |
| | CustomerID | Name | OrderID | CustomerID | OrderItem | | |
| +------------+-----------+---------+------------+-----------+ | |
| | 1 | Nathan | 1 | 1 | boots | | |
| | 2 | James | 5 | 2 | shirt | | |
| | 2 | James | 2 | 2 | socks | | |
| | 3 | Brauer | 6 | 3 | scarf | | |
| | 3 | Brauer | 3 | 3 | pants | | |
| | 4 | The First | 4 | 4 | shorts | | |
| +------------+-----------+---------+------------+-----------+ | |
| 6 rows in set (0.00 sec) |
Author
mysql> select * from Customer c left outer JOIN (`Order` o) on (c.CustomerID=o.CustomerID) order by c.CustomerID;
+------------+-----------+---------+------------+-----------+
| CustomerID | Name | OrderID | CustomerID | OrderItem |
+------------+-----------+---------+------------+-----------+
| 1 | Nathan | 1 | 1 | boots |
| 2 | James | 5 | 2 | shirt |
| 2 | James | 2 | 2 | socks |
| 3 | Brauer | 6 | 3 | scarf |
| 3 | Brauer | 3 | 3 | pants |
| 4 | The First | 4 | 4 | shorts |
| 5 | Cheeser | NULL | NULL | NULL |
+------------+-----------+---------+------------+-----------+
7 rows in set (0.00 sec)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
select * from
Customerc left outer JOIN (Ordero) on (c.CustomerID=o.CustomerID) order by c.CustomerID;