MySQL realizes that all times of the current data table are increased or decreased by the specified time interval of recommendation

  • 2021-07-03 00:59:35
  • OfStack

The DATE_ADD () function adds the specified time interval to the date.

All data in the current table will be increased by 1 day:


UPDATE ACT_BlockNum SET CreateTime = DATE_ADD(CreateTime, INTERVAL 1 DAY);

All data in the current table is reduced by 1 day:


UPDATE ACT_BlockNum SET CreateTime = DATE_ADD(CreateTime, INTERVAL -1 DAY);

In order to prevent the database query from reporting null exception, when the query result returns to integer type, it can be compared with 0. If it is null, it will return 1 0 to the customer, otherwise, it will return the result value of the query change. sql is as follows


 SELECT IFNULL(SUM(Num),0) from DPEvent.ACT_BlockNum where CreateTime BETWEEN #startTime# AND #endTime#;
MYSQL IFNULL(expr1,expr2)

If expr1 is not NULL, IFNULL () returns expr1, otherwise it returns expr2. IFNULL () returns a number or string value, depending on the context in which it is used. Similar ones are
isnull(expr)

If expr is null, the return value of isnull () is 1, otherwise the return value is 0.

The update statement updates the values of multiple fields


update @A 
set c1=b.c1 ,c2=b.c2,c3=b.c3
from @A a,@B b where a.id=2 and b.id=6
update A
    set (A.a2,A.a3) =(select B.b2,b.b3
    from B
    where B.b1= A.a1 and A.a3=100
    )

Above is this site to introduce you MySQL to achieve the current data table all the time to increase or decrease the specified time interval, I hope to help you, if you have any questions welcome to leave me a message, this site will reply to you in time!


Related articles: