I am trying to query some information from certain large data on connections among a set of clients and servers. Below are sample data from relevant columns in the table (connection_stats):
+---------------------------------------------------------+
| timestamp | client_id | server_id | status |
+---------------------------------------------------------+
| 2013-07-06 10:40:30 | 100 | 800 | SUCCESS |
+---------------------------------------------------------+
| 2013-07-06 10:40:50 | 101 | 801 | FAILED |
+---------------------------------------------------------+
| 2013-07-06 10:42:00 | 100 | 800 | ABORTED |
+---------------------------------------------------------+
| 2013-07-06 10:43:30 | 100 | 801 | SUCCESS |
+---------------------------------------------------------+
| 2013-07-06 10:56:00 | 100 | 800 | FAILED |
+---------------------------------------------------------+
From this table, I am trying to query all instances of the connection status "ABORTED" immediately followed (in the order of timestamp) by connection status "FAILED", for each client_id, server_id pair. I would like to get both the records - the one with status "ABORTED" and that with status "FAILED". There is one such case in the data sample above - for the pair 100, 800, there is a "FAILED" status immediately after "ABORTED".
I am a novice in SQL and databases and I am completely lost on this one. Any pointers to how to approach this will be much appreciated.
The database is mysql.