RT,select * from data_players where from_unixtime(last_login,"%Y-%m-%d")="2011-10-18" and from_unixtime(reg_time,"%Y-%m-%d")="2011-10-18" and sex=1 and reg_site_no="5"
查出684条结果
select pid from data_players where from_unixtime(last_login,"%Y-%m-%d")="2011-10-19" and sex=1 and reg_site_no=5
查出370条结果
select * from data_players where from_unixtime(last_login,"%Y-%m-%d")="2011-10-18" and from_unixtime(reg_time,"%Y-%m-%d")="2011-10-18" and sex=1 and reg_site_no="5" and (pid not in(select pid from data_players where from_unixtime(last_login,"%Y-%m-%d")="2011-10-19" and sex=1 and reg_site_no=5))
仍然是684条结果,请问是NOT IN没起作用么?

解决方案 »

  1.   

    先看下你的第一条查询的684条记录与第一条查询的370条记录有没有相同的pid,如果没有,那就是正确的。。
      

  2.   

    from_unixtime(last_login,"%Y-%m-%d")="2011-10-18"本来就 not infrom_unixtime(last_login,"%Y-%m-%d")="2011-10-19" 
    ,,
    你的语句,还是直接用时间戳比较好,,,如有索引可避免扫全表
      

  3.   


    虽然时间不一样,但也不一定pid就没有重合的吧,除非是主键。。