MySQL: Data pagination according data on another table
1
vote
2
answers
1989
views
I have a database with the following structure
- Items table: itemID, itemName
- Ads table: AdsId, itemID
I would like to make pagination on items table, 10 items in each page, but first I must retrieve items whose IDs are in the Ads table, and then retrieve other items.
I know I must use
limit
such as:
SELECT * FROM Items LIMIT $offset, $no_of_records_per_page
And may I join
ed it with adsTable, such as:
SELECT * FROM Items inner join Ads on Ads.itemID = Items.itemID
LIMIT $offset, $no_of_records_per_page
but how can I achieve what I described?
Thanks in advance.
Asked by Ali A. Jalil
(113 rep)
Feb 4, 2021, 05:38 PM
Last activity: Apr 4, 2025, 12:06 PM
Last activity: Apr 4, 2025, 12:06 PM