在Postgresql 9中,在另一个字段的值更改时自动更新一个字段中的值 [英] Automatic updation of value in one field on change in value of another field in Postgresql 9

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

问题描述

大家好
我有字段date_lastupdate,peiodicity(数据类型为时间间隔),due_date.
我想做的是
当date_lastupdate更改时,定期(每行可能不同),due_date字段将通过以下公式进行更新
due_date = date_lastupdate +定期

当我向
查询时

hi all
i have fields date_lastupdate,peiodicity(data type is interval),due_date.
What i''m trying to do is
when the date_lastupdate changes ,periodicity(which may be different for each row),due_date field gets updated by following formula
due_date=date_lastupdate+periodicity

when i queried with

select areaName,due_date from updation where due_date=date_lastupdate+periodicity




我只得到areaName,due_date列,没有任何记录...
请帮助我

在此先感谢

帕特尔
感谢thanx
这是我的输入错误
我跟你说的一样
但只返回没有记录的列名.




I get only columns areaName,due_date with no records...
plz help me

Thanks in advance

Hi patel
thanx for replying
it was my typing error
i did the same as u told
but only the column names with no records were returned.

推荐答案

尝试一下此操作
Try this
select areaName,due_date from updation where due_date=date_lastupdate+periodicity



为什么使用due_date=due_date+periodicity?



Why do you use due_date=due_date+periodicity?


如果尝试更改due_date字段,则应使用
If you are trying change the due_date field you should be using an update[^] statement.


这篇关于在Postgresql 9中,在另一个字段的值更改时自动更新一个字段中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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