MySQL WHERE
This is the same SELECT idea as before, but now you are not asking for all matching rows blindly. You are adding a condition, and that condition is the WHERE clause.
So instead of saying “give me these columns from this table,” you are now saying “give me these columns from this table, but only for rows that match this rule.”
That is what WHERE does. It filters the result set before PHP even starts looping through it. So if your table has ten rows and only two match the condition, MySQL sends back only those two.
The basic shape is simple: SELECT ... FROM ... WHERE .... The part after WHERE is the condition. In the example, it checks whether lastname equals 'Doe'. If the condition is true for a row, that row is included. If not, it is skipped.
So the useful shift in this lesson is that you are not learning a brand new workflow. The flow is still: write the SQL, run the query, get a result set, loop through it. The new part is just that the result set is filtered before it reaches your PHP code.