gpt4 book ai didi

php - WHERE 或停止 LIKE 工作

转载 作者:太空宇宙 更新时间:2023-11-03 10:51:03 26 4
gpt4 key购买 nike

我让 codeignter 生成这个查询:

SELECT `games_link`.`APPID`, `games_other`.`name`, `games_other`.`logo`, `platforms`.`PID`, `platforms`.`name` AS pname, `platforms`.`logo` AS plogo 
FROM (`games_link`)
LEFT JOIN `games_platforms` ON `games_platforms`.`APPID` = `games_link`.`APPID`
LEFT JOIN `platforms` ON `platforms`.`PID` = `games_platforms`.`PID`
LEFT JOIN `games_other` ON `games_other`.`APPID` = `games_link`.`GB_ID`
WHERE `games_platforms`.`PID` = '94'
OR `games_platforms`.`PID` = '139'
OR `games_platforms`.`PID` = '35'
OR `games_platforms`.`PID` = '129'
OR `games_platforms`.`PID` = '146'
OR `games_platforms`.`PID` = '20'
OR `games_platforms`.`PID` = '145'
AND `games_other`.`name` LIKE '%knack%' LIMIT 15

enter image description here

当它运行时,它不会通过 LIKE 进行过滤,它只会返回所有内容,但是如果我运行它:

SELECT `games_link`.`APPID`, `games_other`.`name`, `games_other`.`logo`, `platforms`.`PID`, `platforms`.`name` AS pname, `platforms`.`logo` AS plogo 
FROM (`games_link`)
LEFT JOIN `games_platforms` ON `games_platforms`.`APPID` = `games_link`.`APPID`
LEFT JOIN `platforms` ON `platforms`.`PID` = `games_platforms`.`PID`
LEFT JOIN `games_other` ON `games_other`.`APPID` = `games_link`.`GB_ID`
WHERE `games_other`.`name` LIKE '%knack%' LIMIT 15

它运行 LIKE。 enter image description here

最佳答案

大概您打算将任何游戏类型与 and 结合使用.但是,您的逻辑不正确,因为您没有括号。修复它的最简单方法是使用 in :

WHERE `games_platforms`.`PID` in (94, 139, 35, 129, 146, 146, 20, 145) and
`games_other`.`name` LIKE '%knack%' ;

以后,在 where 中的条件周围使用括号子句,直到您完全理解 or 的优先级规则和 and .

关于php - WHERE 或停止 LIKE 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25137865/

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