I am struggling to understand basic MySQL joins.
Basically I\'ve got 2 tables one with a customer first name and address id in it and another with the actual address.
SELECT a.name, b.address
FROM Customer a INNER JOIN AddressList b on a.addressID = b.addressID
To learn more about joins, see the article below,
It would be:
SELECT firstName, address FROM Address As A
INNER JOIN Customer as C ON C.addressId=A.addressId
Lets say that you have following tables:
Customer(ID, FName, LName, AddressID)
Address(AddressID, Streeet, HNUmber, City)
This will display customers address instead of AddressID:
SELECT c.ID, c.Fname, c.LName, a.Street, a.HNumber, a.City
FROM Customer c, Address a
WHERE
c.AddressID = a.AddressID
Put the same 'addressid' in both the name and address tables then join the two as:
select name, address from customer join addresses
on customer.addressid = addresses.addressid;
Assuming that both tables have an address id, you could use
SELECT firstname, address, from table1 JOIN table2
ON table1.addressid = table2.addressid
Your condition is inner join, This is the simplest, most understood Join and is the most common. This query will return all of the records in the left table (Customer) that have a matching record in the right table (address). This Join is written as follows:
SELECT firstName, address FROM Customer
INNER JOIN address ON Customer.addressId=address.addressId
SQL_LIVE_DEMO
Sample Output :
FIRSTNAME ADDRESS
Bob 45 Somewhere street