Why does Mysql fuzzy query remove spaces ?? $ SQL = & quot; SELECTmingcFROMinfoWHERE1 = 1 & quot; fuzzy judgment if ($ mingc! = & Quot;) {& nbsp; $ SQL. = & quot; ANDmingclike Mysql fuzzy query to remove spaces question ??
$ SQL = "SELECT mingc FROM info WHERE 1 = 1 ";
Fuzzy Judgment
If ($ mingc! = ""){
$ SQL. = "AND mingc like '% $ mingc % '";
}
Trim ($ mingc)
But the problem is that = first, a space is used to enter the fuzzy condition/or the opposite.
[That is, the left and right spaces are removed at the same time and fuzzy query can be performed]
Wait .......
------ Solution --------------------
Trim () is to remove leading and trailing spaces. what happened today?
------ Solution --------------------
If (! Empty ($ mingc )){
$ SQL. = "AND mingc like '% trim ($ mingc) % '";
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service