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
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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.