Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:05:19+00:00 2026-06-14T22:05:19+00:00

I have a database with a books table and a persons table with around

  • 0

I have a database with a books table and a persons table with around ~100k entries in each. A third table connects the two so they have a many-to-many relationship. Besides columns for book and person id, the connection table also has a column indicating the relation type between the book and the person, fx writer, co-writer or publisher or something else.

I need to make queries that return a list of all book entries with the persons related to them and the specific relation type. When joining the two tables, SQL returns multiple rows for books that have more than one person related to it, so I sort this out in php afterwards. The number of persons related to books varies from book to book with no predictable pattern.

I need to make a pagination system.

What would be the smartest way to do pagination in this situation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:05:20+00:00Added an answer on June 14, 2026 at 10:05 pm

    You can select all related persons per book in one row with group_concat and then paginate the result set with limit offset, num_rows

    select b.book_id, b.title, ..., group_concat(c.type), group_concat(p.name)
    from books b
    join connections c on c.book_id = b.book_id
    join persons p on p.person_id = c.person_id
    group by book_id
    limit 100, 50
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that keeps track of books. The books table looks like
i have a database with 3 tables in a many-to-many relationship. one is the
For example, in my database I have 3 tables, the Books table for storing
I have a book database(2 books in total right now) where for each book
Assume I'm indexing a table of books. They have title, author, description, etc. I
This a very basic database design/normalisation question. Suppose I have a Books table with
i'm having a problem with my database. I have the folowing: create table book
Say I have a database containing Books and Users and these users have certain
i have database with two values id and val so i want to ask
i have database table like this +-------+--------------+----------+ | id | ip | date |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.