mapleleaf Posted June 17, 2010 Share Posted June 17, 2010 Can i put an array into a like search? So select * where like '%myarray%'; Pseudo code. So if the array has 3 words and I want to check if any of them show up? Is it possible with LIKE? Tx Quote Link to comment Share on other sites More sharing options...
Alex Posted June 17, 2010 Share Posted June 17, 2010 No. You will have to use OR like so: SELECT * FROM table WHERE col LIKE '%something%' OR col LIKE '%somethingelse%' If you have an array containing terms you want to use with LIKE you can do something like this: $terms = array( 'term1', 'term2', 'term3' ); $sql = "SELECT * FROM table WHERE col LIKE '%" . implode("%' OR col LIKE '%", $terms) . "%'"; Quote Link to comment Share on other sites More sharing options...
mapleleaf Posted June 17, 2010 Author Share Posted June 17, 2010 perfect thanks Quote Link to comment 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.