I want a query to grab results from 2 different tables where a specific user has added the row. So my 2 tables look like this:
addresses
- id
- address
- user_id
emails
- id
- user_id
So, I want to pull the content from both tables where the user_id row equals 1. For context, imagine each user can add multiple addresses and emails to the site and I want to grab them all to display on their profile pages.
So I tried this:
SELECT *
FROM addresses
JOIN emails USING (user_id)
WHERE user_id = '1'
However this doesn't work - It either returns 2 of each row from the first table, or nothing at all. I also tried this:
SELECT *
FROM addresses,
emails
WHERE user_id = '1'
But this also returns nothing.