MySQL increases or decreases the specified time interval for the current data table.

Source: Internet
Author: User

MySQL increases or decreases the specified time interval for the current data table.

The DATE_ADD () function adds a specified interval to a date.

All data in the current table will be added one day later:

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

 

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

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

To prevent null exceptions in database queries, when the query result is returned as an integer, it can be compared with 0. If it is null, a zero value is returned to the customer. Otherwise, the query result value is changed, the SQL statement 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

Isnull (expr)

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

Update statement to update values of Multiple Fields

 

update @A set c1=b.c1 ,c2=b.c2,c3=b.c3from @A a,@B b where a.id=2 and b.id=6

 

Update

Set (A. a2, A. a3) = (select B. b2, B. b3

From B

Where B. b1 = A. a1 and A. a3 = 100

)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.