Some thoughts on writing complex SQL

Writing complex SQL will not be done in one step. It will process a part of the data in each step through multi-step subqueries, and then combine this part of data with other SQL, nesting multiple times for processing, and finally we can get the results we want. .

This process is very similar to the way we write JAVA code.The complex logic is a step-by-step method that is independent of each other and related to each other.After the layers are called, we can get the final result we want.

Each method is responsible for receiving the data processed by the previous layer, and then in this method, the data is processed again (may be processed directly with the incoming data; it may also depend on the data queried by this method, and The data entered by the method are combined for processing (this is similar to whether a subquery is required)).

What is efficient is to look at the data processing logic, how to index, how fast, but the idea of ​​processing data is the same as JAVA.

Published 331 original articles · 51 praises · 440,000 visits +

Guess you like

Origin blog.csdn.net/y41992910/article/details/104188455