Home  >  Article  >  Backend Development  >  SQL statement (several tables are jointly queried together to obtain the first to tenth piece of data)

SQL statement (several tables are jointly queried together to obtain the first to tenth piece of data)

PHP中文网
PHP中文网Original
2017-03-30 14:01:212942browse

SQL statement (several tables are jointly queried together to obtain the first to tenth piece of data):

1. For example, if there are four tables A, B, C, and D, A, B, C, D are related together such as: ((A Inner join B By A.Id =B.AId) Inner join C By B.Id =C.BId)Inner join D By C.Id =D.CId Where condition one AND condition Two... ; The above is sorted by time. Get the 11th to 20th data from it. How should the sql statement be written?

Reply content:

1. For example, if there are four tables A, B, C, and D respectively, A, B, C, and D are related together, such as: ((A Inner join B By A.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... ; The above is sorted by time. Get the 11th to 20th data from it. How should the sql statement be written?

MySQL:

select * from (select ... from ((A Inner join B By A.Id =B.AId) Inner join C By B.Id =C.BId)Inner join D By 
C.Id =D.CId Where 条件一 AND 条件二... ) as table LIMIT 11,10

The above is the content of the SQL statement (several tables are jointly queried together to obtain the first to tenth piece of data). For more related content, please pay attention to the PHP Chinese website (www.php.cn )!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn