Home > database >  Help mysql a matter of time
Help mysql a matter of time

Time:10-09

Date1 date2
On July 15, July 15
July 16 null
July 17 null
On July 18 July 18
July 19 null
On July 20 null
On July 21 null
July 22 July 22

The above data is null data update for approaching the minimum time
For example, on July 16 and July 17 corresponding two null update for July 15
On July 21st July 19 July 20 corresponding null update for July 18

CodePudding user response:

Resolved
In case the when date2 is null
Then (select Max (date2) as maxtime from table1 where date2 & lt; Date1)
The else date2
End as date2

When date2 is null
From the table to get less than (date1 date2 is null when) the biggest date2

For example when date1=17 July date2 is null
The select Max (date2) from table1 where date1 & lt; 'on July 17'

note: the above date format is not standard, normal should be '2020-07-17'

CodePudding user response:

The MARK of UP
  • Related