Created
May 23, 2016 20:40
-
-
Save dan81989/08d3d24302611c452e8d13b9c5b26ea8 to your computer and use it in GitHub Desktop.
Let’s say we want to find all orders placed by a particular customer. We can do this by joining the customers and orders tables together using the relationship established by the customer_id key.
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
select order_date, order_amount | |
from customers | |
join orders | |
on customers.customer_id = orders.customer_id | |
where customer_id = 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To echo the above comment, I believe there is a typo in this query. In order to have
order_id
included in the results as shown, the query should be:SELECT order_id, order_date, order_amount
FROM customers
JOIN orders
ON customers.customer_id = orders.customer_id
WHERE customer_id = 3