排名和信息导出

  1. SELECT max(a.score),b.usernick,b.college,b.classname,b.realname,c.xuehao
  2. FROM websocket.rank as a
  3. LEFT JOIN glutlife.userinfo_extra AS b on a.userid=b.userid
  4. LEFT JOIN glutlife.userinfo as c on a.userid=c.id
  5. where a.appid=178
  6. GROUP by a.userid,b.usernick,b.college,b.classname,b.realname,c.xuehao
  7. order BY MAX(a.score) DESC limit 30

执行耗时20ms。

活动中奖信息导出

  1. SELECT a.award,b.usernick,b.realname,b.college,b.classname,c.xuehao,IF(b.sex=0,'男','女')
  2. FROM module.getprize_record as a
  3. LEFT join glutlife.userinfo_extra as b on b.userid=a.userid
  4. LEFT join glutlife.userinfo as c on c.id=a.userid
  5. WHERE a.award>0 and a.configid=33
  6. GROUP by b.usernick,b.realname,b.college,b.classname,c.xuehao,a.award,b.sex
  7. order by a.award ASC

轻应用活跃度查询

  1. SELECT distinct b.yb_userid ,c.yb_username,c.yb_realname,c.yb_collegename,c.yb_classname
  2. FROM glutlife.app_tongji_login as a
  3. JOIN glutlife.userinfo as b on b.id=a.userid
  4. JOIN glutlife.yiban_userinfo as c on b.yb_userid= c.yb_userid
  5. WHERE a.createTime>'2020-11-05' AND a.createTime<'2020-12-05'

表中有相同的数据,则跳过,没有相同的数据,则插入

  1. 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')

表中有相同的数据,则跳过,没有相同的数据,则插入

  1. INSERT INTO `table_name`(`field1`,`field2`)SELECT 'FIELD1','filed2' FROM DUAL WHERE NOT EXISTS(子查询)

hell