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 8441567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:35:40+00:00 2026-06-10T08:35:40+00:00

For example, in my database I have 3 tables, the Books table for storing

  • 0

For example, in my database I have 3 tables,

  • the Books table for storing data about books
  • the Tags table for storing data about tags
  • and a link table (the Book_Tags table) for storing information about a book having multiple tags.

Its illustrated in the image below… (“M” above the arrow means the many side of the relationship)

    BOOKS                    BOOK_TAGS                      TAGS
    +----+---------+         +---------+----------+         +----+---------------+
    |ID  |  Title  |         |Book_Id  |  Tags_Id |         |ID  |  Tag_Name     |
    +----+---------+         +---------+----------+         +----+---------------+ 
    |1   |  Book_1 | 1    M  |1        | 1        | M     1 |1   |  Tag_Name_1   |
    |1   |  Book_1 |<--------|1        | 2        |-------->|2   |  Tag_Name_2   |
    +----+---------+         |1        | 3        |         |3   |  Tag_Name_3   |
                             |2        | 1        |         +----+---------------+ 
                             |2        | 3        |         
                             +---------+----------+         

My question is, how do i query my database so that i would get a result something like

    +---------------------------------------------------------+
    |ID  |  Book_Title  |   Tags                              |
    +---------------------------------------------------------+
    |1   |  Book_1      |   Tag_Name_1, Tag_Name_2, Tag_Name_3|
    |2   |  Book_2      |   Tag_Name_1, Tag_Name_3            |
    +---------------------------------------------------------+

And not something like

    +----------------------------------+
    |ID  |  Book_Title  |   Tags       |
    +----------------------------------+
    |1   |  Book_1      |   Tag_Name_1 |
    |2   |  Book_1      |   Tag_Name_2 |
    |3   |  Book_1      |   Tag_Name_3 |
    |4   |  Book_2      |   Tag_Name_1 |
    |5   |  Book_2      |   Tag_Name_3 |
    +----------------------------------+
  • 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-10T08:35:41+00:00Added an answer on June 10, 2026 at 8:35 am

    You can use GROUP BY Clause to aggregate results and do string append. So something like:

    SELECT bk.Book_Title, GROUP_CONCAT(bt.Book_Id SEPARATOR ', ') FROM BOOK_TAGS bt
    JOIN BOOKS bk ON bk.ID = bt.Book_Id
    JOIN TAGS t ON t.ID = bt.Tags_Id
    GROUP BY bt.Book_Id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this example we have 3 related tables on a SQLite database: CREATE TABLE
In my database I have tables that define types for example Table: Publication Types
I have an example database, it contains tables for Movies, People and Credits. The
I have 2 tables in my database, for example: Table1: id (PK), data1 and
I have 3 tables in my database, for example with such names: TableA, TableB,
I have a large database with two tables: stat and total. The example of
Up until now, I have maintained a 'dictionary' table in my database, for example:
I have a database that keeps track of books. The books table looks like
I have a table in a database which is used for storing application configuration
I have a book database(2 books in total right now) where for each book

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.