我有下面列出的查詢,它是從一個PDO語句。除了collectionId = 3部分之外,查詢中的所有內容都可以正常工作。它與其他整數的返回結果...mysql查詢沒有篩選和按預期
我盯着這一段時間,不能發現什麼是錯的,這一切對我來說都很好嗎?
SELECT `Hat`.`id` AS `Hat_id` , `Hat`.`hatCode` AS `Hat_hatCode` , `Hat`.`hatCodeOther` AS `Hat_hatCodeOther` , `Hat`.`name` AS `Hat_name` , `Hat`.`description` AS `Hat_description` , `Hat`.`colorId` AS `Hat_colorId` , `Hat`.`collectionId` AS `Hat_collectionId` , `Hat`.`mainPicture` AS `Hat_mainPicture` , `Hat`.`subPicture` AS `Hat_subPicture` , `Hat`.`type` AS `Hat_type` , `Hat`.`featured` AS `Hat_featured` , `Hat`.`published` AS `Hat_published` , `Hat`.`deleted` AS `Hat_deleted`
FROM `modx_hats` AS `Hat`
WHERE (
`Hat`.`published` =1
AND `Hat`.`collectionId` = '3'
AND `Hat`.`colorId` LIKE '%||2||%'
OR `Hat`.`colorId` LIKE '2||%'
OR `Hat`.`colorId` LIKE '%||2'
OR `Hat`.`colorId` LIKE '2'
)
LIMIT 0 , 30
退房SQL操作precendence這個問題:http://stackoverflow.com/questions/1241142/sql-logic-operator-precedence-and-和 - 或 – vbo
可能重複的[SQL查詢多個AND和OR不工作](http://stackoverflow.com/questions/21096134/sql-query-multiple-and-ors-not-working) – codeling