More than one term in category field???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
imimin
Forum Commoner
Posts: 38
Joined: Thu Oct 18, 2007 5:44 pm

More than one term in category field???

Post by imimin »

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
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: More than one term in category field???

Post by jaoudestudios »

If you are using a MyIsam database engine, then you could do a Full text search.

Or explode the search field on white space and make your WHERE clause with ANDs or ORs.
ie. search term = walked downstairs
...WHERE column1 LIKE '%walked%' AND column1 LIKE '%downstairs%'
Post Reply