lukep11a Posted January 31, 2011 Share Posted January 31, 2011 There is probably a very simple answer to this question so excuse me for sounding dim but its driving me mad, can anyone tell me how to convert the following code to select only the results exactly equal to $var rather than all values like $var: $query = "SELECT * FROM directory WHERE merchant LIKE \"%$var%\""; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { Quote Link to comment https://forums.phpfreaks.com/topic/226283-simple-select-statement-help/ Share on other sites More sharing options...
ale8oneboy Posted January 31, 2011 Share Posted January 31, 2011 Try: $query = "SELECT * FROM directory WHERE merchant = '$var'"; Quote Link to comment https://forums.phpfreaks.com/topic/226283-simple-select-statement-help/#findComment-1168053 Share on other sites More sharing options...
lukep11a Posted January 31, 2011 Author Share Posted January 31, 2011 Thanks mate, perfect Quote Link to comment https://forums.phpfreaks.com/topic/226283-simple-select-statement-help/#findComment-1168059 Share on other sites More sharing options...
Maq Posted January 31, 2011 Share Posted January 31, 2011 For more information, be sure to check out the MySQL Manual for LIKE syntax. Quote Link to comment https://forums.phpfreaks.com/topic/226283-simple-select-statement-help/#findComment-1168063 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.