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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:48:29+00:00 2026-06-18T12:48:29+00:00

I’m creating a search function for my website, and i’ve therefore taken keywords from

  • 0

I’m creating a search function for my website, and i’ve therefore taken keywords from the main table, and summarized these as keys in a secondary table linking to the main table via id.
My setup looks like this:
—————————————————–
| ITEMS    |
—————————————————–
| Id            | Name           | Price                |
—————————————————–
| 1             | CPU              | 199.95            |
| 2             | GPU              | 249.95            |
| 3             | GPU              | 225.95            |
—————————————————–

—————————————————–
| KEYS      |
—————————————————–
| Id            | item_name   | item_id            |
—————————————————–
| 1             | CPU              | 1                     |
| 2             | GPU              | 2                     |
| 3             | GPU              | 3                     |
—————————————————–
Bear in mind my table is more complex, generating many keys for each row.
My problem is that if there are a lot of duplicate keywords, the keywords table becomes very large. My question is therefore:
Is it possible to somehow group the id’s in mySQL for each unique item_name so if someone searches for GPU the out put will be 2 and 3?
I’m thinking you can separate the values in a string using eg. a comma like so:
—————————————————–
| 2             | GPU              | 2,3                  |
—————————————————–
However I feel it gets complicated when for instance an item in items is deleted and I need to update my keys table and maybe remove an Id=5 from the string “1,3,5,7,10,15”…
Is there a smart way of linking same name keys to multiple entries? Or will I always need a regular expression, and maybe even PHP, to separate the values?

  • 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-18T12:48:30+00:00Added an answer on June 18, 2026 at 12:48 pm

    Do not use CSV in a database table, but use a join instead to select the data.

    You should be able to generate the output like so:

    select count(*) as cnt
          ,k.item_name
          ,group_concat(k.item_id) as ids
    from keys k
    inner join items i ON (i.id = k.id)
    where i.price = 199.95
    

    The group_concat will generate the CSV on the fly, so you don’t have to store CSV in the database.
    If you need more than one row of output, you can use a group by clause.

    See: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

    Note that this has nothing to do with regex.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.