Jump to content

Query DB field containing CSV


cimerol

Recommended Posts

Hi All,

 

I have a DB which contains products, and each product has a keyword which can be queried.

 

I want the keywords in the DB field to be comma separated. This way when a user enters a keyword in a search box and clicks submits, you get the results.

 

i.e.

Product 1 Name = Big Bear

Keywords = bear, big bear, polar bear

 

Product 2 Name = Small Bear

Keywords = bear, small bear

 

A user enters the word BEAR into a search box, clicks submit. The results should show both Product 1 & Product 2. Much like how an ecommerce site functions.

 

Any ideas?

 

Thanks,

Norm

Link to comment
https://forums.phpfreaks.com/topic/128467-query-db-field-containing-csv/
Share on other sites

Don't use CSV in fields.  Don't.

 

Possibly make product name be a fulltext, have mysql look for the user so you don't have to make keywords.

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

 

Otherwise, I would suggest 3 tables:

product, keywords, productID_keywordID

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.