Reputation: 1024
I have mysql table called with column name gift_code
which type is varchar(20)
and now it's contain GREATDAY
string data.
Now why I a run following sql query it's return 0. I don't understand why it's happening ?!
The string
can contain Uppercase or Lowercase characters. I want to search exact match
$checkPromo = mysqli_query($conn, "SELECT * FROM gift_card WHERE gift_code = 'GREATDAY' ");
echo $numPromo = mysqli_num_rows($checkPromo);
I used BINARY
keyword but not working :(
Upvotes: 0
Views: 347
Reputation: 954
COLLATE utf8_general_cs
is what matters. When the column's collate is set to this, the case-sensitive will work. if your column collate is utf8_general_ci
this will ignore the case sensitiveness while querying.
Upvotes: 2
Reputation: 199
I think you should try trimming your data in the database , it can contain various unnecessary characters which make the string match return nothing , Or, You can select all data from the database and trim them and compare with "GREATDAY" if its not working you can echo it and go to page source to see if there are any br or p tags ,
Upvotes: 1