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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:55:02+00:00 2026-05-23T02:55:02+00:00

I have the following schema, and would like to do a query that returns

  • 0

I have the following schema, and would like to do a query that returns one row for each entry in the articles table, with it’s corresponding content column from the content table, and a column with each of that articles tags, such as you might get by using concat.

The query should SELECT only rows that match a certain tag. So if the tag atdi was provided, the result set would look something like:

id    content                                                tags
1     on my way nails broke and fell                         song,atdi,invalid
3     im all alone so far up here and my oxygen is all gone  song,atdi,hourglass
4     you know your insides true better than i do            song,atdi,starslight

I’ve tried a few different ways with subqueries, but keep getting errors – it’s quite frustrating.

Here’s the schema:

CREATE TABLE articles (
id int not null default 0,
published datetime,
author int not null default 0,
primary key (id)
);

INSERT INTO articles
(id, published, author)
VALUES
(1, CURRENT_TIMESTAMP, 1),
(2, CURRENT_TIMESTAMP, 1),
(3, CURRENT_TIMESTAMP, 1),
(4, CURRENT_TIMESTAMP, 1);

CREATE TABLE content (
id int not null default 0,
content varchar(250) not null default '',
primary key (id)
);

INSERT INTO content
(id,content)
VALUES
(1,'on my way nails broke and fell'),
(2,'exo skeleton junction at the railroad delayed'),
(3,'im all alone so far up here and my oxygen is all gone'),
(4,'you know your insides true better than i do');

CREATE TABLE tags (
id int not null default 0,
tag varchar(100) not null default '',
primary key (id,tag)
);

INSERT INTO tags
(id,tag)
VALUES
(1,"song"),
(2,"song"),
(3,"song"),
(4,"song"),
(1,"atdi"),
(2,"mars"),
(3,"atdi"),
(4,"atdi"),
(1,"invalid"),
(2,"roulette"),
(3,"hourglass"),
(4,"starslight");
  • 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-23T02:55:03+00:00Added an answer on May 23, 2026 at 2:55 am

    Try something like this one

    select a.id, a.content, b.tags_1 
    from content as a  inner join (
        select id, GROUP_CONCAT(tag SEPARATOR ',') as tags_1 FROM tags group by id
    ) as b on a.id = b.id 
    INNER JOIN tags AS c ON a.id = c.id
    WHERE c.tag = 'atdi'
    

    Using the GROUP_CONCAT() method

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

Sidebar

Related Questions

In a table I have the following schema table1: playerID int primary key, nationalities
I have the following table schema; CREATE TABLE `db1`.`sms_queue` ( `Id` INTEGER UNSIGNED NOT
I have a database schema that is similar to the following: | User |
I have the following table schema in acess (2007). Date eventDate bit(boolean) lunch, bit(boolean)
I have xml file that defines some preference screens like the following example <PreferenceScreen
I have a script that appends some rows to a table. One of the
I have a database where I store objects. I have the following (simplified) schema
I have run across an XML Schema with the following definition: <xs:simpleType name=ClassRankType> <xs:restriction
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following situation. A main table and many other tables linked together with

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.