php - How to use limit and offset to handle pagination in database multi-condition search?
phpcn_u1582
phpcn_u1582 2017-05-16 13:09:44
0
1
370

Part of the table structure is as follows:

 total numeric(20,2), -- statistical amount
  date character varying(50), -- date
  site character varying(50), -- address

Now I want to use a table on the page to output: statistical data corresponding to dates and addresses. One date can correspond to multiple addresses. An address can also correspond to multiple dates, but a date and an address can uniquely determine a record.
I now make statistics based on the date group by, and then search for the corresponding address for each date. In this way, some dates contain multiple addresses, and some dates only contain case of an address. At this time, I cannot use limit and offset to display data in pages. Now I have collected all the data, but this paging cannot be implemented.
How can this problem be solved? Thanks.

phpcn_u1582
phpcn_u1582

reply all(1)
小葫芦

No matter how complex your query is, you can use limit and offset to paginate.

select * from (
  select a, b, c
  from ...
  where ...
  ...
) 
order by a, b, c
limit xx
offset xx;
 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template