I am trying to do a query on my MySQL database. I want it to be case insensitive. If “RED” exists in the database and I search for “red”, I want the result to show.
Unfortunately, this query is being case-senstivie and I dont know why:
$color = "red";
$size = "large";
$query = mysql_query("SELECT * FROM items WHERE color = '$color' OR size = '$size'");
while ($row = mysql_fetch_array($query)) {
if ($color == $row['color']) {
echo "The color exists in the database";
}
if ($size == $row['size']) {
echo "The size exists in the database";
}
}
Using this example, “RED” exists in the database, but it’s not being found.
What’s wrong with the query?
Because the collation of you column is case sensitive