two inner join in one query code example

Example 1: two inner joins

SELECT 
  c.*, i.*, a.* 
FROM 
  invoices i 
INNER JOIN 
  client c 
ON 
  i.clientid = c.clientid 
INNER JOIN 
  address a 
ON 
  a.clientid = c.clientid 
WHERE 
  i.id = 21

Example 2: multiple joins mysql

SELECT dashboard_data.headline, dashboard_data.message, dashboard_messages.image_id, images.filename
FROM dashboard_data 
    INNER JOIN dashboard_messages 
        ON dashboard_message_id = dashboard_messages.id
    INNER JOIN images
        ON dashboard_messages.image_id = images.image_id

Tags:

Sql Example