I want the paging script to work fine, but the situation is a bit complicated. I need to select data from a union of two sql queries. See Request below. I have a dining book and a bookcase. I want to show here all the books for a certain category in the order of their popularity. I get data for all books with at least one visit, joining the table book and scribe. and then combine it with all the books without visiting. Everything works fine, but when I try to swap, I need to limit it, like (0,10) (10,10) (20,10) (30,10), right? If I have 9 books in bookvisit for this category and 3761 books without visiting this category (3770 books in total), it should display 377 pages, 10 books on each page. but he does not show any data for some pages, because he is trying to show books with a limit of 3760.10 and, therefore, there are no records for the second request in the union. Maybe I cannot clear the situation here, but if you think a little about the situation, you will get my point of view.
SELECT * FROM ( SELECT * FROM ( SELECT viewcount, b.isbn, booktitle, stock_status, price, description FROM book AS b INNER JOIN bookvisit AS bv ON b.isbn = bv.isbn WHERE b.price <> 0 AND hcategoryid = '25' ORDER BY viewcount DESC LIMIT 10, 10 ) AS t1 UNION SELECT * FROM ( SELECT viewcount, b.isbn, booktitle, stock_status, price, description FROM book AS b LEFT JOIN bookvisit AS bv ON b.isbn = bv.isbn WHERE b.price <> 0 AND hcategoryid = '25' AND viewcount IS NULL ORDER BY viewcount DESC LIMIT 10, 10 ) AS t2 ) AS qry ORDER BY viewcount DESC LIMIT 10
source share