gpt4 book ai didi

mysql - 将列日期设置为另一个表日期列加上 30 天

转载 作者:行者123 更新时间:2023-11-30 00:50:41 24 4
gpt4 key购买 nike

我有 2 张 table :

新表

ID____PersonID___Criteria___TimeStamp
1_____456________1__________01/08/2014
2_____287________0__________01/08/2014
3_____359________0__________01/08/2014

人员表

ID______LastLogin
456_____11/08/2013
287_____10/25/2013
359_____09/15/2013

我想做的是将 NewTable.TimeStamp 更新为等于 PersonTable.LoginDate PLUS 30 天,其中 NewTable.Criteria = 0

期望的结果

新表

ID____PersonID___Criteria___TimeStamp
1_____456________1__________01/08/2014
2_____287________0__________11/24/2013
3_____359________0__________10/15/2013

我尝试过,尽管这些似乎没有任何作用:

UPDATE NewTable AS NT
INNER JOIN PersonTable AS PT ON PT.ID = NT.PersonID AND NT.Criteria = 0
SET NT.TimeStamp = DATE_ADD(PT.LastLogin, INTERVAL 30 DAY);

--我已经尝试过了

UPDATE `NewTable` AS NT, PersonTable AS PT
SET NT.TimeStamp = DATE_ADD(PT.LastLogin, INTERVAL 30 DAY)
WHERE NT.PersonID = PT.ID
AND NT.Criteria = 0;

最佳答案

UPDATE  NewTable AS NT INNER JOIN PersonTable AS PT 
ON PT.ID = NT.UserID
SET NT.TimeStamp = DATE_ADD(PT.LastLogin, INTERVAL 30 DAY)
WHERE NT.Criteria = 0

关于mysql - 将列日期设置为另一个表日期列加上 30 天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21006354/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com