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 Link to comment https://forums.phpfreaks.com/topic/205111-using-an-array-with-like/ 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) . "%'"; Link to comment https://forums.phpfreaks.com/topic/205111-using-an-array-with-like/#findComment-1073662 Share on other sites More sharing options...
mapleleaf Posted June 17, 2010 Author Share Posted June 17, 2010 perfect thanks Link to comment https://forums.phpfreaks.com/topic/205111-using-an-array-with-like/#findComment-1073671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.