sql query to join multiple tables code example
Example 1: using multiple join in sql
SELECT e.FIRST_NAME ,
d.DEPARTMENT_NAME ,
l.CITY ,
c.COUNTRY_NAME ,
r.REGION_NAME
FROM EMPLOYEES e
INNER JOIN DEPARTMENTS d on e.DEPARTMENT_ID = d.DEPARTMENT_ID
INNER JOIN LOCATIONS l on l.LOCATION_ID = d.LOCATION_ID
INNER JOIN COUNTRIES c on l.COUNTRY_ID = c.COUNTRY_ID
INNER JOIN REGIONS r on c.REGION_ID = r.REGION_ID ;
Example 2: join multiple tables in sql
SELECT Books_Namn, Author_Namn, Author_Age, Store_Namn FROM books
JOIN Author ON Author_Id = Author_Author_Id
JOIN Books_has_Store ON Books_Books_Id = Books_Id
JOIN Store ON Store_Id = Store_Store_Id;