V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Layne  ›  全部回复第 8 页 / 共 16 页
回复总数  320
1  2  3  4  5  6  7  8  9  10 ... 16  
2016-07-27 14:53:54 +08:00
回复了 wangyu1314 创建的主题 MySQL 请帮忙看看这两条 MySQL 语句问题出在何处?
@wangyu1314 看一下 between 语句后面的月份加减对不对,我用的是 date_add 函数,然后前溯的话应该是负数参数,或者用你习惯的日期函数来写
2016-07-27 14:27:53 +08:00
回复了 wangyu1314 创建的主题 MySQL 请帮忙看看这两条 MySQL 语句问题出在何处?
把 exists 去掉呢?

自查询限制了 postuserid = userid ,取得的 max(dateline) 应该就是对应用户的最大值
2016-07-27 13:15:42 +08:00
回复了 wangyu1314 创建的主题 MySQL 请帮忙看看这两条 MySQL 语句问题出在何处?
@wangyu1314

试试这样:

select *
from
/*update*/ user u
/* set u.money = 0.5 * u.money */
where u.membergroupids != 27
and u.money > 0
and exists (
select max(t.dateline) from thread t where t.postuserid = u.userid
and t.forumid in (56,57,60,62,67,65,70,71,73,178,75,76,77,109,189,186,81,83,88,89,74,175,181,85,74,175,79,80,165,193,172,59)
) between date_add(now(), interval -4 month) and date_add(now(), interval -4 month)
;
2016-07-27 11:02:38 +08:00
回复了 wangyu1314 创建的主题 MySQL 请帮忙看看这两条 MySQL 语句问题出在何处?
@wangyu1314 写 update 时,可以先把查询逻辑部分写好,然后更新需要处理的字段,以我写的第一句来看,查询逻辑为:

select *
from
/*update*/ user u
/* set u.money = 0.5 * u.money */
where u.membergroupids != 27
and u.money > 0
and exists (
select 1 from thread t where t.postuserid = u.userid
and t.dateline between date_add(now(), interval -4 month) and date_add(now(), interval -4 month)
and t.forumid in (56,57,60,62,67,65,70,71,73,178,75,76,77,109,189,186,81,83,88,89,74,175,181,85,74,175,79,80,165,193,172,59)
);

调整这个查询逻辑,直到能查询出你需要更新的数据,然后再 update 对应字段即可。

写 update 语句时我一般习惯不用表关联,如果查询逻辑本身就特别复杂,就用存储过程来处理,或者用程序来处理了。
2016-07-27 00:38:48 +08:00
回复了 wangyu1314 创建的主题 MySQL 请帮忙看看这两条 MySQL 语句问题出在何处?
不知道数据量有多少,用 exists 和 not exists 会不会在效率上有巨大差异,

另外,没有环境验证,不确定能不能执行,我只是个数据渣…

update user u
set u.money = 0.5 * u.money
where u.membergroupids != 27
and u.money > 0
and exists (
select 1 from thread t where t.postuserid = u.userid
and t.dateline between date_add(now(), interval -4 month) and date_add(now(), interval -4 month)
and t.forumid in (56,57,60,62,67,65,70,71,73,178,75,76,77,109,189,186,81,83,88,89,74,175,181,85,74,175,79,80,165,193,172,59)
);


update user u
set u.money = 0.5 * u.money
where u.membergroupids != 27
and u.money > 0
and not exists (
select 1 from thread t where t.postuserid = u.userid
and t.forumid in (56,57,60,62,67,65,70,71,73,178,75,76,77,109,189,186,81,83,88,89,74,175,181,85,74,175,79,80,165,193,172,59)
);
2016-07-12 11:08:07 +08:00
回复了 samuel40 创建的主题 问与答 国内 Office(主要是 word 和 excel)电脑和移动端同步最佳方案
是要通过把文件保存在 OneDrive 同步的。。或者其他网盘。。
发邮件求改差评。。

虽然挺 low 的,不过不能称作「邮件轰炸」吧?
Apple Store
我记得好像在搜狗输入法这些输入法出现之前,智能 ABC 、全拼之类的输入法,「/」一直都不是顿号。。
2016-07-01 19:02:19 +08:00
回复了 unstop 创建的主题 推广 番茄土豆小卖部上线了!回贴赢取免费 T 恤和笔记本!
黑色 T 恤印上 logo 还挺好看的。
2016-06-14 15:13:19 +08:00
回复了 also24 创建的主题 分享发现 Office365 家庭版续费姿势,约 10 元/月
买了 Office 365 企业版, 80 CNY/月, Exchange + Office 套件
2016-06-14 10:22:49 +08:00
回复了 vlike 创建的主题 macOS 搜狗输入法,偷偷在写硬盘?
@liushuaikobe 双拼说起来都是泪,我用的原生输入法,于是硬生生从用了几年的微软方案换成了智能 ABC 方案……
然后工作用的 Windows 10 原生输入法又只支持微软方案……
2016-05-20 22:49:33 +08:00
回复了 linode 创建的主题 Android Sunrise 被微软下架了, Android 下还有什么好用的日历工具?
买了 Office 365 的 Exchange Online 计划 1 ,每用户每月 25 RMB ,在 iPhone 和 Mac 上都用 Exchange ,目前还比较方便。
2016-04-07 22:26:55 +08:00
回复了 Mireas 创建的主题 问与答 支付宝不让我用了....
反洗钱呀,上头各种机构盯着呢
2016-03-24 10:40:42 +08:00
回复了 zungmou 创建的主题 问与答 大家在办公室都以喝什么为主?
最近在喝苏打水
2016-03-12 13:10:30 +08:00
回复了 JiaFeiX 创建的主题 分享发现 Notepad.Live 增加加密云笔记功能
URL 用我自己名字,然后加了密码,然后现在忘了。。。 http://ww3.sinaimg.cn/bmiddle/62e721e4gw1et02ek7u61j200k00k3y9.jpg
2016-03-11 16:08:31 +08:00
回复了 Winny 创建的主题 iPhone 失望与失落: iPhone 6s Plus 128G 使用 2 月有感
如果没越狱就去售后检测吧
2016-03-11 16:05:53 +08:00
回复了 songz 创建的主题 支付宝 支付宝又出了个大新闻
这篇文章我不能转发,提示发布微博出错。。
1  2  3  4  5  6  7  8  9  10 ... 16  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2402 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 48ms · UTC 08:53 · PVG 16:53 · LAX 01:53 · JFK 04:53
Developed with CodeLauncher
♥ Do have faith in what you're doing.