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)) { 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'"; 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 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. Link to comment https://forums.phpfreaks.com/topic/226283-simple-select-statement-help/#findComment-1168063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.