我基本上是在mySQL查询期间尝试两次使用NOT IN函数 我的新当前查询如下
SELECT `o`.`id`, `o`.`name`, `o`.`url`, `o`.`type`, `o`.`desc` FROM `offers` as `o`
WHERE `o`.country_iso = '$country_iso' AND `o`.`id` not in
(select distinct(offer_id) from conversions where ip = '$_SERVER[REMOTE_ADDR]'
and converted != '0') AND `o`.`id` not in
(select `offer_id` from `aff_disabled_offers` where `offer_id` = 'o.id'
and `user_id` = '1') ORDER by rand() LIMIT $limit
查询有效但由于某种原因它完全忽略了这个
AND `o`.`id` not in
(select `offer_id` from `aff_disabled_offers` where `offer_id` = 'o.id')
答案 0 :(得分:1)
您需要在条件之间指定运算符,例如AND或OR。您还需要在NOT IN子句中有效查询。
SELECT `o`.`id`, `o`.`name`, `o`.`url`, `o`.`type`, `o`.`desc`
FROM `offers` as `o`
WHERE `o`.country_iso = '$country_iso'
AND `o`.`id` not in (select distinct(offer_id)
from converstions where
from conversions
where ip = '$_SERVER[REMOTE_ADDR]'
and converted != '0')
AND `o`.`somevar` not in (select `somevar` from
`sometable` where `offer_id` = 'o.id')
ORDER by rand() LIMIT 0,6