我正在尝试在php PDO中执行查询,但是执行方法导致HTTP错误500
$query = "select * from job_t where title like '%:title%' and salary>=:salary";
$st = $conn->prepare($query);
$st->bindParam(":title", $_GET['title']);
$st->bindParam(":salary", $_GET['salary']);
$st->execute();
预期输出是来自job_t的表,但实际结果是http错误500
答案 0 :(得分:2)
此'%:title%'
不起作用..
尝试使用concat构建适当的like子句
$query = "select * from job_t
where title like concat('%', :title, '%') and salary>=:salary";