Chrome Extension

Apply JOIN on multiple columns of the tables MySql

You can easily apply multiple JOIN conditions while joining two tables. You can use OR operator or AND operator for this purpose.
--using OR operator
Select 
    employee.name, employee.email, employee_address.street
FROM Employee
INNER JOIN employee_address
    ON employee.Id = employee_address.employee_id 
    OR employee.pincode = employee_address.street_code 
    OR employee.parmanent_code = employee_address.location_code 

--using AND operator
Select 
    employee.name, employee.email, employee_address.street
FROM Employee
INNER JOIN employee_address
    ON employee.Id = employee_address.employee_id 
    AND employee.pincode = employee_address.street_code 
    AND employee.parmanent_code = employee_address.location_code
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

Search Index Data (The code snippet can also be found with below search text)

multiple conditions based JOIN between two tables
AND JOIN
OR JOIN
Was this helpful?
0 Comments
Join Devsheet Ask a Question