Amit Dhamu

Software Engineer

Case Insensitive MySQL Select

To search for in a MySQL database where the user is actually listed as

$search = "";
$sql_search = mysql_query("SELECT email FROM users WHERE LOWER(email) = LOWER('$search')");
echo mysql_error();

You may be thinking why didn't I just use strtolower on $search and query the database normally. Well because you might not always know the value of $search as it might be an incoming form value. In this example, Joe Bloggs might know his email address as Joe.Bloggs but you have him in your database as joe.bloggs.

case insensitive / ignore case / mysql / select

← RSS Structure Hover Animations →