There is often such a scenario: the data of the indicator is displayed in the table on the page. If the data of the indicator does not exist, the name of the indicator will not be displayed. In fact, sometimes it is necessary to display the name, because in this way, the content of the page area can be known, and no data is another matter. Therefore, we need to have a certain understanding of the execution principle of sql, so as not to take too many detours .
The following SQL:
SELECT * FROM Class c LEFTJOIN Student s ON c.ClassID=s.ClassID AND s.StudentID='hhhhll'
is to filter s first, and then join
The following SQL:
SELECT * FROM Class c LEFTJOIN Student s ON c.ClassID=s.ClassID
WHERE s.StudentID='llllffff'
It is to join first, and then filter the data.
For the second case, if there are no students, the courses will not be displayed, and the existing courses will not be visible.