SQL statement (several tables are combined for query to obtain the first to tenth data Records)

Source: Internet
Author: User
This article describes in detail how to sort combined queries in SQL statements. if you are interested, refer to the following. SQL statement (several tables are combined for query to obtain the first to tenth data records ):

1. for example, tables A, B, C, and D are associated with tables A, B, C, and D respectively. for example:(A Inner join B By. id = B. AId) Inner join C By B. id = C. BId) Inner join D By C. id = D. CId Where condition 1 AND condition 2 ...;It is sorted by time. Obtain 11th to 20th data records. How should I write SQL statements?

Reply content:

1. for example, tables A, B, C, and D are associated with tables A, B, C, and D respectively. for example:(A Inner join B By. id = B. AId) Inner join C By B. id = C. BId) Inner join D By C. id = D. CId Where condition 1 AND condition 2 ...;It is sorted by time. Obtain 11th to 20th data records. How should I write SQL statements?

MySQL:

Select * from (select... from (A Inner join B By. id = B. AId) Inner join C By B. id = C. BId) Inner join D By C. id = D. CId Where condition 1 AND condition 2 ...) as table LIMIT 11,10

The above is the content of the SQL statement (several tables are jointly queried to obtain the nth to tenth pieces of data). For more information, see The PHP Chinese website (www.php1.cn )!

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.