Jump to content

an sql querry puzzle


rickyj

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

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.