In my view, the FROM clause is where I decide which columns I need in the rows for my SELECT clause. This expresses a business rule that displays on the same line the values needed in the calculations. A business rule can be a customer who has invoices, as a result of which invoices are built, including customer liability. It can also be places in the same zip code as customers, leaving a list of places and customers that are close to each other.
Here I determine the centricity of the rows in my result set. In the end, we are simply shown the metaphor of the list in the RDBMS, and each list has a topic (entity), and each line is an instance of the object. If we understand the centricity of the rows, we understand the object of the result set.
The WHERE clause, which is conceptually executed after the lines defined in the from clause, selects rows that are not required (or contain lines that are required) for the SELECT clause to work.
Since join logic can be expressed in both the FROM clause and the WHERE clause, and because there are sentences for dividing and overcoming complex logic, I choose to put the join logic, which includes the values in the columns in the FROM clause, because it is essentially expressing a business rule that is supported by matching values in columns.
i.e. I will not write the WHERE clause as follows:
WHERE Column1 = Column2
I will put this in the FROM clause as follows:
ON Column1 = Column2
Similarly, if a column should be compared with external values (values that may or may not be in the column), for example, comparing a zip code with a specific zip code, I will put this in a WHERE clause because I basically say I only need such rows .
i.e. I will not write the FROM clause as follows:
ON PostCode = '1234'
I will put this in the WHERE clause as follows:
WHERE PostCode = '1234'
John Oct 18 '14 at 20:51 2014-10-18 20:51
source share