开发者

LCASE where search

开发者 https://www.devze.com 2023-02-20 18:12 出处:网络
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?

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 f开发者_开发问答ieldt = '" .$_POST['thisf']. "'");


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']). "')");


Assuming I did not introduce a bunch of syntax errors:

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

精彩评论

暂无评论...
验证码 换一张
取 消