$sql = "SELECT id, trader_currency FROM active_trades WHERE status=? AND open_time IN (LIKE ?, LIKE ?, LIKE ?)";
$q = $conn->prepare($sql);
$result = $q->execute(array("Closed", "%".$todayDate."%", "%".$yesterdayDate."%", "%".$last2dayDate."%"));
如何在pdo中组合like子句和in子句?上面的代码有语法错误。
答案 0 :(得分:1)
只需OR
条件:
$sql = 'SELECT id, trader_currency, open_time
FROM active_trades
WHERE status=?
AND (
open_time LIKE ?
OR open_time LIKE ?
OR open_time LIKE ?
)';