表结构:
+---------------+-------------+----------------+-----------+--------------------------+
| column_name | is_nullable | column_default | data_type | character_maximum_length |
+---------------+-------------+----------------+-----------+--------------------------+
| id | NO | NULL | int | NULL |
| name | NO | NULL | varchar | 100 |
| last_start | YES | NULL | datetime | NULL |
| y | YES | NULL | varchar | 4 |
| m | YES | NULL | varchar | 2 |
| d | YES | NULL | varchar | 2 |
| h | YES | NULL | varchar | 2 |
| i | YES | NULL | varchar | 2 |
| s | YES | NULL | varchar | 2 |
+---------------+-------------+----------------+-----------+--------------------------+
表数据:
+----+-------------------------+---------------------+------+------+------+------+------+------+
| id | name | last_start | y | m | d | h | i | s |
+----+-------------------------+---------------------+------+------+------+------+------+------+
| 55 | daemon_service_service | 2019-08-21 11:05:59 | NULL | NULL | NULL | NULL | NULL | NULL |
| 56 | daemon_ohrclean_service | 2019-08-21 10:47:59 | NULL | NULL | NULL | 05 | 00 | 00 |
| 57 | daemon_mqclean_service | 2019-08-21 10:47:59 | NULL | NULL | NULL | NULL | NULL | NULL |
| 58 | daemon_loggrab_service | 2019-08-21 10:59:59 | NULL | NULL | NULL | NULL | NULL | NULL |
| 59 | daemon_test1 | 2019-08-20 12:26:31 | NULL | NULL | 20 | 11 | 25 | 30 |
| 60 | daemon_test2 | 2019-08-20 12:26:31 | NULL | NULL | 20 | 11 | 25 | 30 |
| 61 | daemon_test3 | 2019-08-20 12:26:31 | NULL | NULL | 20 | 11 | 25 | NULL |
+----+-------------------------+---------------------+------+------+------+------+------+------+
sql语句:
SELECT t.*, concat(ifnull(`y`,date_format(now(),'%Y')),'-',
ifnull(`m`,date_format(now(),'%m')),'-',
ifnull(`d`,date_format(now(),'%d')),' ',
ifnull(`h`,date_format(now(),'%H')),':',
ifnull(`i`,date_format(now(),'%i')),':',`s`)
FROM `daemon_service` t
where
`s` is not null and
last_start< concat(ifnull(`y`,date_format(now(),'%Y')),'-',
ifnull(`m`,date_format(now(),'%m')),'-',
ifnull(`d`,date_format(now(),'%d')),' ',
ifnull(`h`,date_format(now(),'%H')),':',
ifnull(`i`,date_format(now(),'%i')),':',`s`)
问题发生时的日期是2019年8月21日,上述sql语句正确的运行结果是无结果。
sql环境有两个,MariaDB 10.3.15
和Mysql 5.7.24
MariaDB 10.3.15
下运行结果无误,而在Mysql 5.7.24
下返回的错误结果为id 59 和 60
想请问:
1、是什么导致这个错误
2、如何在Mysql 5.7.24
下解决