同一张表里面查询不同的内容比较

SELECT b.* FROM
(SELECT ip,DATE_FORMAT(FROM_UNIXTIME(createtime),"%Y%m%d") AS createtime FROM InApp_AdLog WHERE  appid=6 AND bgtype=1  ) AS a, 
(SELECT ip,DATE_FORMAT(FROM_UNIXTIME(createtime),"%Y%m%d") AS createtime FROM InApp_AdLog WHERE    appid=6 AND bgtype=2  ) AS b
WHERE a.ip=b.ip   GROUP BY b.ip ORDER BY createtime ASC

 

posted @ 2013-06-19 11:04  jshaibozhong  阅读(190)  评论(0编辑  收藏  举报