如何在PDO执行语句中修复HTTP错误500?

时间:2019-06-05 15:06:17

标签: php mysql pdo

我正在尝试在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

1 个答案:

答案 0 :(得分:2)

'%:title%'不起作用..

尝试使用concat构建适当的like子句

$query = "select * from job_t 
  where title like concat('%', :title, '%')  and salary>=:salary";