networkthis Posted November 14, 2008 Share Posted November 14, 2008 I am fairly new to mysql, I have a question on the following: I am trying to match keywords entered into my search all box with any of the fields in my table as long as my status field is set to active: This works great as long as I use only 1 LIKE field, however when I enter multiple LIKE fields into my query I get a different number of search results if I reverse the words.... <?php if ($search_all) { foreach ($search_all_array as $trimm){ $query = "SELECT * FROM db WHERE long_description LIKE '%$trimm%' OR short_description LIKE '%$trimm%' OR city LIKE '%$trimm%' AND status LIKE '%active%'";} ?> Any ideas?? Thanks Link to comment https://forums.phpfreaks.com/topic/132666-mysql-query-question/ Share on other sites More sharing options...
revraz Posted November 14, 2008 Share Posted November 14, 2008 Probably because it will stop on the first match. Link to comment https://forums.phpfreaks.com/topic/132666-mysql-query-question/#findComment-690165 Share on other sites More sharing options...
Mchl Posted November 14, 2008 Share Posted November 14, 2008 SELECT * FROM db WHERE (long_description LIKE '%$trimm%' OR short_description LIKE '%$trimm%' OR city LIKE '%$trimm%') AND status = 'active; Link to comment https://forums.phpfreaks.com/topic/132666-mysql-query-question/#findComment-690171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.