[ad_1]
So long as you click on into this text, I’m fairly positive it is best to perceive SQL. You should additionally perceive that we should always put our situations within the WHERE clause in a SELECT question. Nevertheless, let me ask you a query and see in the event you can reply it instantly.
What is going to occur if we put a filter situation with LEFT JOIN … ON … clause?
SELECT *
FROM Worker e LEFT JOIN Division d
ON e.dept_id = d.id
AND e.title = 'Chris'
In case you are uncertain concerning the behaviour of the above question or suppose it’s equal to the next one, please learn my article and I’ll let you know why they’re totally different.
SELECT *
FROM Worker e LEFT JOIN Division d
ON e.dept_id = d.id
WHERE e.title = 'Chris'
For demonstration functions, I’ve created two tables with easy dummy information as follows.
The Worker Desk
The Division Desk
Now, let’s run the primary question within the introduction. On your reference, I’ll put the question right here once more.
SELECT *
FROM Worker e LEFT JOIN Division d
ON e.dept_id = d.id
AND e.title = 'Chris'
That was the reply. Have been you proper? 🙂
Only for comparability functions, I’ll additionally put the 2nd question and its outcomes right here. Of…
[ad_2]