gpt4 book ai didi

mysql - pdo LIKE 子句和 IN 子句

转载 作者:行者123 更新时间:2023-11-29 10:45:07 25 4
gpt4 key购买 nike

$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子句?上面的代码有语法错误。

最佳答案

简单地通过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 ?
)';

关于mysql - pdo LIKE 子句和 IN 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44738546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com