954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Simple search question

Hello everyone. This is my first post to this site. I've used it before as a reference and now I'm here with a question of my own.

I'm currently storing some data in a row like this:
"apples, oranges, pears, bananas, peaches"

Basically the row contains just a few terms separated by commas.

I need some help to formulate a SQL search statement on this row. Say the search term is "pears,peaches". Using the row above as a reference I want it to return results for any match of the search term in the row.

Search terms:
"pears,peaches" would return results
"bananas,oranges,apples" would return results
"apples" would return results

etc.

I've tried using the LIKE command. However it seems that some of my results are being left out because of the way I have the search terms formulated and the data setup.

Any ideas?

Thanks,
Tegan

tegansnyder
Newbie Poster
2 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

I just marked my row as "FULL TEXT" in phpMyAdmin.

Now I'm able to use the niffy search terms.
"SELECT txt FROM {my_table} WHERE MATCH txt AGAINST ('$txt' IN BOOLEAN MODE)"

tegansnyder
Newbie Poster
2 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You