I have to get data from two SQL tables but I am unsure of what join to use and the same tables have the same customers_id table would I use an inner join?
table - customers
customers_id
customers_firstname
customers_lastname
customers_email_address
table - orders
customers_id
customers_street_address
customers_suburb
customers_city
customers_postcode
customers_state
customers_country
It depends on what results you want. If you want every record in Customers regardless of whether there is a matching record in orders the you would use an
LEFT OUTER JOIN. If not you would use anINNER JOIN. This is the article I typically refer people to for a basic explanation of joins.An
INNER JOINwould look like this:I purposely did not do
select *. Try to get into the habit of only selecting the columns you want from tables instead of everything.