Jump to content

select words from description field


RichardRotterdam

Recommended Posts

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

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.

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);

 

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.