RichardRotterdam Posted May 7, 2008 Share Posted May 7, 2008 Ok maybe someone can help me with this one. I have a table with recipies and one of the fields is called description recipy_id|recipy_name|recipy_description 1|fruit pie|apple banana pears plumes 2|soup|basel tomatoes 3|blt|bacon lettuce tomato now i want to perform a select query which will get the words depending on the input for example perform a select words from recipies where description like %b this should return basil, banana , bacon how can i achieve this? Quote Link to comment https://forums.phpfreaks.com/topic/104600-select-words-from-description-field/ Share on other sites More sharing options...
fenway Posted May 7, 2008 Share Posted May 7, 2008 You're storing the ingredients as a list in a single field. Database don't like that. Quote Link to comment https://forums.phpfreaks.com/topic/104600-select-words-from-description-field/#findComment-535420 Share on other sites More sharing options...
RichardRotterdam Posted May 7, 2008 Author Share Posted May 7, 2008 actually i just made that to simplify my situation. The description field is usually one line of human readable text. and i want to filter the words from it. Quote Link to comment https://forums.phpfreaks.com/topic/104600-select-words-from-description-field/#findComment-535477 Share on other sites More sharing options...
fenway Posted May 8, 2008 Share Posted May 8, 2008 actually i just made that to simplify my situation. The description field is usually one line of human readable text. and i want to filter the words from it. Well, it's not that simple anymore, is it? You won't be able to do what you want. Quote Link to comment https://forums.phpfreaks.com/topic/104600-select-words-from-description-field/#findComment-535869 Share on other sites More sharing options...
mezise Posted May 8, 2008 Share Posted May 8, 2008 Hi, in two steps you may do this: SELECT recipy_description FROM recipies WHERE `recipy_description` REGEXP "[[:<:]]b" ; Next you apply regular expression on returned recipy_description fields. E.g. for PHP use $matches = array(); preg_match_all("/\b(b.*)\b/U", $row['recipy_description'], $matches); Quote Link to comment https://forums.phpfreaks.com/topic/104600-select-words-from-description-field/#findComment-536361 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.