Jump to content

Recommended Posts

 

 

    * Edit post

    * Delete post

    * Report this post

    * Reply with quote

 

More than one term in category field???

 

Postby imimin on Tue Mar 31, 2009 3:49 pm

I am setting up a SQL query that will be used to filter search results with a WHERE clause. In my MySQL DB, I have set up a "cat" column. Is there a way to enter more than one term in the cat field so I can give each row more than one category (such as 'child,solid')? I tried using an "," and ";" delimiter, but neither worked. It seems to only work if I have only one category in the cat field.

 

Thanks in advance for any help!

 

Gary

 

Link to comment
https://forums.phpfreaks.com/topic/151981-more-than-one-term-in-category-field/
Share on other sites

Instead of storing the results delimited by a character just make a new record for each one with the same category.  You can use an auto-incremented id to identify them uniquely.

 

You should read more into Database normalization.

I am sorry for my elementary questions or if I am not using proper terminology, my knowledge of DBs is fairly basic.  I appreciate any help you can give me as I am learning.

 

What I am saying is I have a series of products.  Some of the products have more than one category.  I have one row for each product and I have a SINGLE category field (cat).  I would like to be able put more than one category in the the my 'cat' field either separated by a space, comma or something that is permissible in a database field.  I will be "searching" that filed with a WHERE clause and populating a web page with the results.

 

Pudge1, I am not sure what you mean by "$category = $category1 . ' ' . $category2 .

Instead of trying to write to it twice"?  Do you mind explaining?

 

Maq, when you say "make a new record for each one with the same category" do you mean make duplicate rows for each product with various categories and only change the record by giving it a different category?  For example, if product number '123' has 3 possible categories (style, color, size), I make 3 identical rows for product number '123' with the only difference in the rows being the value of the category in the 'cat' field (style, color, size)?

 

Thanks again guys for your help, I REALLY appreciate it!

 

Gary

I would like to be able put more than one category in the the my 'cat' field either separated by a space, comma or something that is permissible in a database field.

No.

I make 3 identical rows for product number '123' with the only difference in the rows being the value of the category in the 'cat' field (style, color, size)?

Yes.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.