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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:10:26+00:00 2026-06-09T21:10:26+00:00

I got a product table like this id | name | category ————————– 1

  • 0

I got a product table like this

id   |   name   | category 
--------------------------
1    |   name1  |  2,1,5,8,9
2    |   name2  |  2,1
3    |   name3  |  5,8

And I got a category table like this

id   |   catname   
----------------
1    |   cat_name1  
2    |   cat_name2  
5    |   cat_name3 
8    |   cat_name3 
9    |   cat_name3 

Each product can have multiple categories. Categories associated with that product are saved in a row named “category” in product table as “1,5,8,7”, Where each represent category table’s id.

Now I want to display all the products came under a specific category.

I am little bit confused with the query to handle this.

And is this the correct format for saving such type of data ?
Please advice

  • 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-09T21:10:27+00:00Added an answer on June 9, 2026 at 9:10 pm

    I would add an extra Table for product-category mapping.

    SELECT p.name 
     FROM products p 
       JOIN product_category pc ON  p.id=pc.prod_id 
       JOIN Category c ON c.id = pc.categ_id
     WHERE c.name='Category' 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got m2m relationship like this: #main table CREATE TABLE products_product ( id integer
I've got a table setup like so: [ReferredID], [Name] 1, Irwin 2, Marc 1,
I've got a MS SQL 2008 table called fruits that looks like this: id
Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
I have table product(table name) product_id product_name product_image product_price product_description category_id category(table name )
I got a table like this (just look at Col1 and Col2) ID Col1
I've got a table that looks like this: CREATE TABLE CustomerXmlData (CustomerId int, CustomerData
I've got a column oriented table that specifies manufacturing options for a product. Each
I'm sitting with this SELECT statement I got ONE product separated into 5 products,
I've got a settings table constructed with 'category' determining different products, 'varname' being the

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.