Table A (ID, type):ID Type----------------------------------1 1 2 1 3 2table B (ID,class):IDclass---------------------------------1 12 2SQL statement 1:select a. *, b.* from a leftJoinB on a.id = b.id and A.type = 1; SQL statement 2:select a. *, b.* from a leftJoinB on a.id = b.id where A.type = 1; SQL statement 3:select a. *, b.* from a leftJoinB on a.id = b.ID and B.class= 1The result of SQL statement 1 is: a. ID A.type b.id B.class----------------------------------------1 1 1 12 1 2 23 2The result of SQL Statement 2 is: a. ID A.type b.id B.class----------------------------------------1 1 1 12 1 2 2The result of SQL Statement 3 is: a. ID A.type b.id B.class----------------------------------------1 1 1 12 1 3 2visible by SQL statement 1, leftJoinall of the records in the left table will be queried, and the conditions on the back are not working on it, unless you add the "where" to filter, this is SQL Statement 2, which is visible by SQL statement 3, and the constraints on the right table will work in the following conditions. **********************************************************************************SQL statement 4:select a. *, b.* from a innerJoinB on a.id = b.id and A.type = 1; SQL statement 5:select a. *, b.* from a innerJoinB on a.id = b.id where A.type = 1; SQL statement 6:select a. *, b.* from A, b where a.id = b.id and A.type = 1; SQL statement 7:select a. *, b.* from A, b where A.type = 1 and a.id = B.The result of the execution of these four statements is as follows: a. ID A.type b.id B.class----------------------------------------1 1 1 12 1 2 2thus, innerJoinThe restrictions that follow in on will all work, as is the case with where. In addition, the where statement and the inner join do get the same result, but the efficiency is different (I haven't tested it, but I believe it). But if SQL statement 6 is less efficient than SQL statement 7, I don't have enough data to test, but I do believe so.
The difference between on and where in a left join, inner join in an SQL statement