由于某种原因,我无法让这个SQL查询工作。我能做错什么?我是否正确连接?
$search_query= "SELECT * FROM users WHERE lname LIKE %'".$search_term."'%"
答案 0 :(得分:6)
将代码重写为:
$search_query= "SELECT * FROM users WHERE lname LIKE '%".$search_term."%'"
答案 1 :(得分:4)
$search_query = "SELECT * FROM users WHERE lname LIKE '%".$search_term."%'";
答案 2 :(得分:3)
您将%
放在单引号之外。
$search_query= "SELECT * FROM users WHERE lname LIKE '%".$search_term."%'";
答案 3 :(得分:3)
您应该将百分比字符放在引号内:
$search_query= "SELECT * FROM users WHERE lname LIKE '%".$search_term."%'"
答案 4 :(得分:1)
$search_query= "SELECT * FROM users
WHERE lname LIKE '%".$string."%'";
答案 5 :(得分:0)
查看差异
%' '%
$ search_query =“SELECT * FROM users WHERE lname LIKE'%”。$ search_term。“%'”;