排名和信息导出
SELECT max(a.score),b.usernick,b.college,b.classname,b.realname,c.xuehaoFROM websocket.rank as aLEFT JOIN glutlife.userinfo_extra AS b on a.userid=b.useridLEFT JOIN glutlife.userinfo as c on a.userid=c.idwhere a.appid=178GROUP by a.userid,b.usernick,b.college,b.classname,b.realname,c.xuehaoorder BY MAX(a.score) DESC limit 30
活动中奖信息导出
SELECT a.award,b.usernick,b.realname,b.college,b.classname,c.xuehao,IF(b.sex=0,'男','女')FROM module.getprize_record as aLEFT join glutlife.userinfo_extra as b on b.userid=a.useridLEFT join glutlife.userinfo as c on c.id=a.useridWHERE a.award>0 and a.configid=33GROUP by b.usernick,b.realname,b.college,b.classname,c.xuehao,a.award,b.sexorder by a.award ASC
轻应用活跃度查询
SELECT distinct b.yb_userid ,c.yb_username,c.yb_realname,c.yb_collegename,c.yb_classnameFROM glutlife.app_tongji_login as aJOIN glutlife.userinfo as b on b.id=a.useridJOIN glutlife.yiban_userinfo as c on b.yb_userid= c.yb_useridWHERE a.createTime>'2020-11-05' AND a.createTime<'2020-12-05'
表中有相同的数据,则跳过,没有相同的数据,则插入
INSERT INTO `money`(`name`, `tag1`, `tag2`,`tag3`,`tag4`,`old_price`, `new_price`, `image`,`image2`) SELECT '$name','$tag1','$tag2','$tag3','$tag4','$price_old','$price_new','$img','$img1'FROM DUAL WHERE NOT EXISTS(SELECT name from money where image='$img')
表中有相同的数据,则跳过,没有相同的数据,则插入
INSERT INTO `table_name`(`field1`,`field2`)SELECT 'FIELD1','filed2' FROM DUAL WHERE NOT EXISTS(子查询)
