title: A Sql statement gets different results on Maria DB and Mysql
body: <p>Table structures is:</p>
  
  <pre><code>+---------------+-------------+----------------+-----------+--------------------------+
  | 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 |
  +---------------+-------------+----------------+-----------+--------------------------+
  </code></pre>
  
  <p>Data in Table is:</p>
  
  <pre><code>+----+-------------------------+---------------------+------+------+------+------+------+------+
  | 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 |
  +----+-------------------------+---------------------+------+------+------+------+------+------+
  </code></pre>
  
  <p>SQL statement is:</p>
  
  <pre><code>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&lt; 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`)
  </code></pre>
  
  <p>I have two sql environment, one is <code>MariaDB 10.3.15</code>, other one is <code>Mysql 5.7.24</code>.</p>
  
  <p>when I run the sql above on <code>MariaDB 10.3.15</code>,The result returns is correct, which is nothing.</p>
  
  <p>But When I run the sql on <code>Mysql 5.7.24</code>, it returns  <strong>id 59 and 60</strong>, which is not correct.</p>
  
  <p>Here are the result:</p>
  
  <pre><code>+----+-------------------------+---------------------+------+------+------+------+------+------+---------------------+
  | id | name                    | last_start          | y    | m    | d    | h    | i    | s    | concat(ifnull(`y`...|
  +----+-------------------------+---------------------+------+------+------+------+------+------+---------------------+
  | 59 | daemon_test1            | 2019-08-20 12:26:31 | NULL | NULL | 20   | 11   | 25   | 30   | 2019-08-20 11:25:30 |
  | 60 | daemon_test2            | 2019-08-20 12:26:31 | NULL | NULL | 20   | 11   | 25   | 30   | 2019-08-20 11:25:30 |
  +----+-------------------------+---------------------+------+------+------+------+------+------+---------------------+
  </code></pre>
  
  <p>My question is:</p>
  
  <ol>
  <li>What cause this problem?</li>
  <li>How to make it correct on <code>Mysql 5.7.24</code>?</li>
  </ol>