Home >Backend Development >PHP Tutorial >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):
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?
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 )!