我有 2 条选择语句,一条用于获取最新的失败状态,一条用于获取最新的错过状态。在第三个中,如果最新状态是错过或失败但它似乎已经合并了数据,我需要有一个声明?我使用 LIKE 因为错过和失败可能会略有不同
mysql> select max(scheduled_start),node_name,schedule_name,status from `events_server` WHERE status LIKE '%Failed%'and node_name='name';
+----------------------+----------------+---------------+-----------+
| max(scheduled_start) | node_name | schedule_name | status |
+----------------------+----------------+---------------+-----------+
| 2013-01-30 15:00:00 | name | name_1500 | Failed 1 |
+----------------------+----------------+---------------+-----------+
1 row in set (0.01 sec)
mysql> select max(scheduled_start),node_name,schedule_name,status from `events_server` WHERE status LIKE '%Missed%'and node_name='name';
+----------------------+----------------+---------------+--------+
| max(scheduled_start) | node_name | schedule_name | status |
+----------------------+----------------+---------------+--------+
| 2013-01-23 08:00:00 | name | NAME_0800 | Missed |
+----------------------+----------------+---------------+--------+
1 row in set (0.01 sec)
mysql> select max(scheduled_start),node_name,schedule_name,status from `events_server` WHERE (status LIKE '%Failed%' OR status LIKE '%Missed%') and node_na
me='name';
+----------------------+----------------+---------------+--------+
| max(scheduled_start) | node_name | schedule_name | status |
+----------------------+----------------+---------------+--------+
| 2013-01-30 15:00:00 | name | NAME_0800 | Missed |
+----------------------+----------------+---------------+--------+
1 row in set (0.01 sec)