triple inner join code example

Example 1: sql inner join

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;

Example 2: 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 3: 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