Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2296016
  • 博文数量: 276
  • 博客积分: 5998
  • 博客等级: 大校
  • 技术积分: 5175
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-24 14:43
文章分类

全部博文(276)

文章存档

2014年(25)

2013年(11)

2012年(69)

2011年(167)

2010年(4)

分类: Mysql/postgreSQL

2012-04-01 13:15:15


点击(此处)折叠或打开

  1. CREATE TABLE if not exists tmp_c5online_table(
  2.         `role_name` VARCHAR(255) NOT NULL
  3. );

  4. insert into tmp_c5online_table
  5. SELECT distinct(r.account)
  6. FROM
  7.         hdzm_gamedb.RolesTable r
  8.         ,hdzm_log.role_duration_log as l
  9.         ,hdzm_log.role_duration_log as l0
  10.         ,hdzm_log.role_duration_log as l1
  11.         ,hdzm_log.role_duration_log as l2
  12.         ,hdzm_log.role_duration_log as l3
  13.         ,hdzm_log.role_duration_log as l4
  14. where
  15.         DATEDIFF(now(), l0.online_date) = 0 and l0.role_name = l.role_name
  16.         and DATEDIFF(now(), l1.online_date) = 1 and l1.role_id = l.role_id
  17.         and DATEDIFF(now(), l2.online_date) = 2 and l2.role_id = l.role_id
  18.         and DATEDIFF(now(), l3.online_date) = 3 and l3.role_id = l.role_id
  19.         and DATEDIFF(now(), l4.online_date) = 4 and l4.role_id = l.role_id
  20.         and r.role_id = l.role_id
  21. ;

  22. insert into xxx_gamedb.AccountsAward (`account`, `awards`, `award_time`, `award_type`)
  23. select role_name, "3300012:10;5040000:5;5040002:1", now(), 1001
  24. from tmp_c5online_table c2
  25. where
  26. role_name not in (
  27.         select c5.role_name from tmp_c5online_table c5, xxx_gamedb.AccountsAward a
  28.         where
  29.         c5.role_name = a.account
  30.         and DATEDIFF( now(), a.award_time) <= 4
  31.         and a.award_type = 1001
  32. )
  33. ;

  34. drop table tmp_c5online_table;

阅读(1864) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~