SQL query records

Source: Internet
Author: User
I have been working on. NET for a while. If I don't know SQL, it must be false, but do I really understand it?

I have been working on. NET for a while. If I don't know SQL, it must be false, but do I really understand it?

Not necessarily, I have never studied SQL query in depth before, recently bought a T-SQL query book, the previously ignored problems are recorded

In the past, I used SQL server as a relational database, which is used to manage data in relational words in the form of tables. Later, some SQL statements look strange and I have no idea how to manage it.

Actually

"Writing SQL statements requires a method of thinking oriented to declarations and sets, rather than process-oriented (set is the focus)." (PS: tables in the database are a set, the set is unordered !)

I have never paid too much attention to the logic sequence of SQL statement execution before. During the research on linq, linq emphasizes the execution sequence of SQL statements. I also paid attention to it when reading books.

(5) select (5-2) distinct (5-3) top ( ) (5-1)
(1) from (1-j) Join On
| (1-a) Apply As
| (1-p) Partition ( )
| (1-u) Unregister ( )
(2) where
(3) group
(4) having
(6) order


We can see that

The first phase is from: identifies the query source and processes the table (SET) operator.

In the second stage, where is selected based on the predicate (query condition ).

The third stage is gruop by grouping based on the specified list name.

The fourth stage is having's selection based on the predicates in having.

The fifth stage is select.

The sixth phase is to sort order by specified columns.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.