how to multiple join in sql code example

Example 1: join multiple tables sql

SELECT TableA.*, TableB.*, TableC.*, TableD.*
FROM TableA
    JOIN TableB
        ON TableB.aID = TableA.aID
    JOIN TableC
        ON TableC.cID = TableB.cID
    JOIN TableD
        ON TableD.dID = TableA.dID
WHERE DATE(TableC.date)=date(now())

Example 2: How to use multiple join in mysql

SELECT 
    t1.name name,
    t1.id id,
    t1.add_date add_date, 
    t2.soc_township township_name1,
    t2.soc_name soc_name,
    t3.name township_name
FROM block t1 
INNER JOIN society t2
    ON (t1.soc_id = t2.id)
INNER JOIN township t3
    ON (t2.soc_township = t3.id)

Tags:

Php Example