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没起作用么?
查出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没起作用么?
,,
你的语句,还是直接用时间戳比较好,,,如有索引可避免扫全表
虽然时间不一样,但也不一定pid就没有重合的吧,除非是主键。。