根据另一个表的字段值更新字段 [英] Update Field based on another table's Field values

查看:46
本文介绍了根据另一个表的字段值更新字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据另一个文件名lastmodification"更新一个名为outofdate"(输入日期:2015-01-14 10:03:11)的文件.我想在outofdate"字段中添加 10 天,其中 :outofdate <;NOW()(实际日期)

i want to update a filed named "outofdate"(type date : 2015-01-14 10:03:11 ) based on another filed name "lastmodification" . i want to add 10 days to "outofdate" field where :outofdate < NOW() (actual date)

我的代码不起作用:

Update *
`mytable` set outofdate = lastmodification + 84500*10
WHERE  outofdate < NOW( ) LIMIT 0,100

提前谢谢!

推荐答案

Update *?那不是有效的语法.我觉得其他的基本没问题:

Update *? That is not valid syntax. I think the rest is basically ok:

Update mytable
    set outofdate = lastmodification + interval 10 day;
    WHERE outofdate < NOW( )
    LIMIT 0, 100;

请注意,一天中的秒数不是 84,500.此外,对于日期/时间数据类型,请使用 date_add()interval 加法.

Note that the number of seconds in a day is not 84,500. Also, for date/time data types, use date_add() or interval addition.

这篇关于根据另一个表的字段值更新字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆