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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:41:15+00:00 2026-06-06T18:41:15+00:00

I have two tables with a single common field. Here is how these two

  • 0

I have two tables with a single common field.
Here is how these two table structures are

Table 1

+--ID--+--Title----+----others---+
| 123  | Title 1   | other values|
| 124  | Title 2   | other values|
| 125  | Title 3   | other values|
| 126  | Title 4   | other values|
+------+-----------+-------------+

Table 2

+--ID--+--Tag ID--+----others---+
| 123  |   11     | other values|
| 123  |   12     | other values|
| 123  |   13     | other values|
| 123  |   14     | other values|
| 124  |   15     | other values|
| 124  |   16     | other values|
| 125  |   17     | other values|
| 126  |   18     | other values|
+------+----------+-------------+

I want to show that Article ID 123 have 4 tags i.e 11,12,13 & 14 like the table below

+--Article ID--+--Article Title--+--Tags--+--Tag IDs------+
|     123      |    Title 1      |    4   | 11, 12, 13, 14|
|     124      |    Title 2      |    2   |     15, 16    |
|     125      |    Title 3      |    1   |        17     |
|     126      |    Title 4      |    1   |        18     |
+--------------+-----------------+--------+---------------+

I’m very new to PHP and MySQL and trying to learn it.

Someone please help me to know how I can get the desired result.

  • 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-06T18:41:16+00:00Added an answer on June 6, 2026 at 6:41 pm
    SELECT t1.id AS 'Article ID',
    t1.title AS 'Article Title', 
    count( t2.tag_id ) AS 'Tags', 
    GROUP_CONCAT( t2.Tag_Id order by t2.Tag_id ASC) AS `Tag IDs`
    FROM table1 t1
    JOIN table2 t2 ON ( t1.id = t2.id )
    GROUP BY t1.id;
    

    Hope this works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables Orders table and customers table, both have customerid as common
I have many tables.But there are Two columns common in each table. They are
I have two tables that are considered a single entity in my domain model.
I have two tables described below. What I need is a single query that
I have two tables, lets say table1 and table2 with common columns, id and
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have used joins to get data from two tables under common name, as
On a single page, I have two tables. Each of them has a class

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.