Jump to content

Recommended Posts

Does anyone know how to put the following in to a query

 

WHERE At least one of the words in the phrase "srch" must contain at least on of the words  in "this_column"

 

for instance if srch = "this is a puzzle"

and on one of the rows this_column = "a puzzle search phrase"

so the where statement is true for this row.

Link to comment
https://forums.phpfreaks.com/topic/67233-an-sql-querry-puzzle/
Share on other sites

for example :

 

WHERE this_column Like '%srch%"'

 

solves if  srch = "puzzle"

and this_column = "a puzzle search phrase"

 

but doesnt solve the case where

for instance if srch = "this is a puzzle"

and on one of the rows this_column = "a puzzle search phrase"

 

- It might be possible to split srch, via ' ', and then check for each of the arrays eg:

 

$splitSrch = split(' ', $srch)

  and then use:

WHERE (this_column Like '%splitSrch[0]%'
         Or this_column Like '%splitSrch[1]%' ...)

but $srch may not always contain two words... hmm, must be an easier way of doing this

Link to comment
https://forums.phpfreaks.com/topic/67233-an-sql-querry-puzzle/#findComment-337264
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.