$request_id_col
和$request_id
是字符串。但是,表中的request_id_col类型是整数。
$stmt = $db->prepare(' SELECT r.qty, d.name
FROM requested_devices r
JOIN devices d ON r.device_id = d.id
WHERE r.:request_id_col = :request_id
ORDER BY r.id');
$stmt->bindParam(':request_id_col', $request_id_col);
$stmt->bindParam(':request_id', $request_id);
$stmt->execute();
我收到错误
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''sample_id' = '101' ORDER BY r.id' at line 4'
如何正确使用bindParam' s进行查询?
答案 0 :(得分:1)
您无法绑定表名或列名。只有价值观。