Search code examples
phpmysqllowercase

LCASE where search


I'd like to search using the WHERE statement, but case-insensitive. I was told I could use LCASE(), but how would I do this with the following?

mysql_query("SELECT * FROM table WHERE fieldt = '" .$_POST['thisf']. "'");

Solution

  • You can trick it witht making both (field and needed data) in Upper/Lover case:

    mysql_query("SELECT * FROM table WHERE UCASE(fieldt) Like UCASE('" .strtoupper($_POST['thisf']). "')");