I write a raising of ads in the list on the site (pagination will be used) It is necessary that the paid ads were at the top of the list, and free at the bottom, while you need to update the ads. Well, of course, you need to make sure that free ones are updated among freebies, and paid ones among paid ones. It needs to be implemented somehow in one request, so that you can use pagination, the forward position of the last displayed entry and the number of entries on the page. How to do it? Tried to connect 2 requests through UNION, but you can sort only once at the end of the entire request.

  • 3
    Sorting can be done not only by fields, but also by descriptive conditions, for example order by case when тип=платное then 1 else 2 end, дата will be paid first and already within these groups will sort by date - Mike
  • Thanks, helped - Vadim Moroz

0