mySQL“不在”查询抛出错误

mySQL“不在”查询抛出错误,mysql,Mysql,我基本上是在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[

我基本上是在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') 

您需要在条件之间指定运算符,例如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

希望您尝试添加而不是加入…完整的错误消息是什么?请阅读关于引用的内容:由于某些原因,这也不起作用,以下是我使用的代码`$sql=SELECT o.id,o.name,o.url,o.type,o.desc FROM offers as o WHERE o.country_iso='$country_iso'和o.id不在select distinctoff_id和o.id不在select offer_id FROM aff_disabled_offers WHERE offer_id='o.id'和user_id='1',从ip='$'服务器[远程地址]转换并转换!='0'兰特订单`我帖子里的一些代码放错地方了。如您所见,select DISTICTOFFER\u id不完整。我现在已经更新了我的答案。我已经更新了我目前的帖子来解释这个问题