The following is a detailed analysis of the difference between on and where in the SQL statement Left_join, Inner_join, and the friends you need can refer to
table A (ID, type):
ID Type
----------------------------------
1 1
2 1
3 2
table B (ID, Class):
ID Class
---------------------------------
1 1
2 2
SQL statement 1:select a.*, b.* from the left of join B on a.id = b.id and a.type = 1;
SQL statement 2:select a.*, b.* from the left of join B on a.id = b.id where a.type = 1;
SQL statement 3:select a.*, b.* from the left of join B on a.id = b.id and b.class = 1;
the execution result of
SQL statement 1 is:
a.id a.type b.id b.class
----------------------------------------
1 1 1 1
2 1 2 2
3 2
The execution result of SQL Statement 2 is:
a.id a.type b.id b.class
----------------------------------------
1 1 1 1
2 1 2 2
The execution result of SQL Statement 3 is:
a.id a.type b.id b.class
----------------------------------------
1 1 1 1
2 1
3 2
Visible from SQL statement 1, all of the records in the left table will be displayed in all queries, the condition on the back does not work for it, unless it is followed by a where to filter it, which is SQL Statement 2, which is visible by SQL statement 3, and the constraint on the right table in the following conditions will work.
**************************************************************************
SQL statement 4:select a.*, b.* from inner join B on a.id = b.id and a.type = 1;
SQL statement 5:select a.*, b.* from a inner join B on a.id = b.id where a.type = 1;
SQL statements 6:select a.*, b.* from A, b where a.id = b.id and a.type = 1;
SQL statements 7:select a.*, b.* from A, b where A.type = 1 and a.id = b.id;
The results of these four statements, as follows:
a.id a.type b.id b.class
----------------------------------------
1 1 1 1
2 1 2 2
This shows that the constraints on the back of the inner join will all work, which is the same as where the execution results are. In addition, the where statement and the inner join do get the same result, but the efficiency is different (which I have not tested, but I believe this conclusion).
But SQL statement 6 is less efficient than SQL statement 7, I don't have enough data to test, but I believe so.