1SELECT TableA.*, TableB.*, TableC.*, TableD.*
2FROM TableA
3 JOIN TableB
4 ON TableB.aID = TableA.aID
5 JOIN TableC
6 ON TableC.cID = TableB.cID
7 JOIN TableD
8 ON TableD.dID = TableA.dID
9WHERE DATE(TableC.date)=date(now())
10
1-- LEFT OUTER JOIN is equivalent to LEFT JOIN
2-- b.VALUE1 is null when ID not in table2 (idem for c.VALUE1 in table3)
3SELECT a.ID, a.NAME, b.VALUE1, c.VALUE1 FROM table1 a
4 LEFT OUTER JOIN table2 b ON a.ID = b.ID
5 LEFT OUTER JOIN table3 c ON a.ID = c.ID
6WHERE a.ID >= 1000;
7
8-- ⇓ Test it ⇓ (Fiddle source link)
1-- Rows with ID existing in both a, b and c
2-- JOIN is equivalent to INNER JOIN
3SELECT a.ID, a.NAME, b.VALUE1, c.VALUE1 FROM table1 a
4 JOIN table2 b ON a.ID = b.ID
5 JOIN table3 c ON a.ID = c.ID
6WHERE a.ID >= 1000;
7-- ⇓ Test it ⇓ (Fiddle source link)
1SELECT column-names
2 FROM table-name1 JOIN table-name2
3 ON column-name1 = column-name2
4 WHERE condition
1Suppose we are having three table named as
2Student_details
3Attendance_details
4Batch_details
5And we have to apply join these three tables for fetching records
6
7Example query:
8select column_names
9from Student_detail as s join Attendance_details as a on
10s.s_id = a.s_id join Batch_details as b on
11s.s_id = b.s_id;
12
13Here in the above example we implemented simple join but you change it with own join requirements.