当我搜索'新德里'时不工作但是当我搜索诺伊达时,它工作正常。当String有空格时如何使用LIKE。
$area = $_REQUEST('area');
$sql = "SELECT * from Student_registration WHERE area LIKE %".$area."%";
答案 0 :(得分:3)
搜索条件周围缺少引号
"SELECT * from Student_registration WHERE area LIKE '%". $area."%'";
或
"SELECT * from Student_registration WHERE area LIKE concat('%', '" .$area. ",'%'";
答案 1 :(得分:2)
您缺少围绕字符串的单引号:
$sql = "SELECT * from Student_registration WHERE area LIKE '%".$area."%'";