MySQL Multiple Left Joins in one Query

The SQL LEFT JOIN (specified with the keywords LEFT JOIN and ON) joins two table or more tables and fetches all matching rows of two table or more tables for which the SQL-expression is true, plus rows from the frist table that do not match any row in the second table.

Code

$sql = "SELECT wo_jobs.* FROM wo_jobs LEFT JOIN wo_clients ON wo_clients.id = wo_jobs.client_id LEFT JOIN wo_sectors ON wo_sectors.id = wo_jobs.sector_id WHERE wo_jobs.jobcode = '154' "; 
$result = mysqli_query($con,$sql);

Leave a Reply

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