php – 如何在mysql中使用长字符串值
作者:互联网
我正在尝试在mysql中使用LIKE语句
我正在尝试搜索的值是
例如:
(999) 999-9999
(999) 888-8888
(888) 888-8888
(888) 999-9999
当我想要搜索的时候
(888)或(999)
它显示得很好,但是当我在寻找时
999-9999 or 888-8888
价值不会显示
数据库的PHP脚本:
if($area != "" & $phone != ""){
$phone = $area.' '.$phone;
$s_phone = " AND pros_num ='$phone'";
}else if($area == "" & $phone != "")
$s_phone = " AND pros_num LIKE '$phone%'";
else
$s_phone = " AND pros_num LIKE '$area%'";
解决方法:
通配符位于错误的位置:
$s_phone = " AND pros_num LIKE '%$phone'";
[编辑]
http://www.tizag.com/mysqlTutorial/mysqlwhere.php将提供有关通配符使用的指导.
标签:php,mysql,sql-like,phone-number 来源: https://codeday.me/bug/20190718/1494040.html