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

  • SEARCH
  • Home
  • 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 7496227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:32:17+00:00 2026-05-29T18:32:17+00:00

i have a database with 3 tables in a many-to-many relationship. one is the

  • 0

i have a database with 3 tables in a many-to-many relationship. one is the books, the other is the authors and the third is their junction (used to join the two). the database is MySQL

a book can be made by many authors, and authors make many books.

enter image description here

now i want to get the books (with authors) like say 8 books at a time. i made this query:

//first table
SELECT * FROM `books`

//join the junction 
LEFT JOIN books_authors ON books.book_id = books_authors.book_id

//join the authors
LEFT JOIN authors ON books_authors.author_id = authors.author_id

//limit to 8, start at S
limit S, 8

works fine when one-to-one. but when a book has more authors, like say 3 each, the sql result will have 8 x 3 rows in total (due to the 2D nature of the result) for all the details. but the query still clips it to 8 – i don’t get all the details.

how to get 8 books with all details?

  • 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-05-29T18:32:20+00:00Added an answer on May 29, 2026 at 6:32 pm

    You could limit the number of books in a subquery:

    select  * 
    from    (
            select  *
            from    books
            limit   6, 7
            ) b
    left join 
            ba ba
    on      b.book_id = ba.book_id
    left join 
            authors a
    on      ba.author_id = a.author_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database with two different tables, connected with one to many relationship.
I have two database tables with a one-to-many relationship. Is it possible to select
Scenario I have 3 database tables. One is for Images and the other two
I have a question about One-To-Many relationship between two tables when there is the
I have a database with many tables and one particular table has columns: name
The tables authors and books are in a many to many relationship. A book
I have a database structure that has two one-to-many relationships. I have a website,
I have two tables in a 2010 Access Database. One for Customers and One
I have the following tables in my database that have a many-to-many relationship, which
Let's say I have the following tables in a database forming a Many-to-Many Relationship.

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.