rickyj Posted August 29, 2007 Share Posted August 29, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/67233-an-sql-querry-puzzle/ Share on other sites More sharing options...
rickyj Posted August 29, 2007 Author Share Posted August 29, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/67233-an-sql-querry-puzzle/#findComment-337264 Share on other sites More sharing options...
rickyj Posted August 29, 2007 Author Share Posted August 29, 2007 a simple java solution would be: (after splitting Srch into array) this_column.indexOf(splitSrch) != -1 but have no idea how to put this into an sql statement. Please HELP.. Quote Link to comment https://forums.phpfreaks.com/topic/67233-an-sql-querry-puzzle/#findComment-337287 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.