MySQL Understanding Basic Joins

前端 未结 6 1873
借酒劲吻你
借酒劲吻你 2021-01-06 20:57

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.

6条回答
  •  佛祖请我去吃肉
    2021-01-06 21:55

    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
    

提交回复
热议问题