I have a table which stores actions. There's two special types of action, let's say for example, "Wake up" and "Go to bed".
All actions BETWEEN "Wake up" and "Go to bed" should return an extra field with the value "AWAKE". If the action is before "Wake up" or after "Go to bed", it should return an extra field with the value "ASLEEP". (These are just example values, try not to take them too seriously.)
+--------+-----------+
| ac_id | ac_name |
+--------+-----------+
| 1 | Talk |
+--------+-----------+
| 2 | Wake Up |
+--------+-----------+
| 3 | Walk |
+--------+-----------+
| 4 | Go to bed |
+--------+-----------+
| 5 | Scream |
+--------+-----------+
With this structure, if I make a query with SELECT ac_name, ac_status FROM actions_table WHERE ac_name = 'Walk' it should return :
ac_name: Walk
ac_status: AWAKE
...because "Walk" is between "Wake Up" and "Go to bed".
My question is how, in the same query and without making any extra queries, I can return that value depending on the "position" of the row?
It's possible I am demanding too much on MySQL, but if I can do so I'd like to know how. If this is not possible in a single query, STORE PROCEDURES or FUNCTIONS are accepted too.
EDIT There can be more than one "Wake Up" and more than one "Go to bed" in the table.