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? 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. 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. 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. 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); 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
Archived
This topic is now archived and is closed to further replies.