How to use multiple join in mysql

MySQL Multiple Joins in one query?

If you have 3 Tables, Table1, Table2, Table3 and you want some data from Table1 , some from Table2, and some from Table3 then follow below sql query using JOIN.

Here is a example,
If you have 3 tables named : township, society, block then you want

You can simply add another join like this:

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)

Related Searches for How to use multiple join in mysql

Tags:,
3 Comments

Add a Comment

Your email address will not be published. Required fields are marked *