I’m working on a MySQL database like this:
----------------------------------------------
| ID | Time | Typeop | Operator |
----------------------------------------------
| 1 | 10:01 | withdrawal | John |
| 2 | 10:01 | deposit | Mike |
| 3 | 10:01 | deposit | Andrew |
| 4 | 10:02 | check | John |
| 5 | 10:02 | withdrawal | Simon |
| 6 | 10:03 | withdrawal | Dorothy |
The database is populated by each “operator” during his operations and shows an hypotetic bank operations database.
My question is:
How can i organize a mysql query to show the activity of each different operator in the last 3 minutes?
In the case of this example the query must show:
-------------------------
| Operator | Typeop |
-------------------------
| Dorothy | withdrawal |
| Simon | withdrawal |
| John | check |
| Andrew | deposit |
| Mike | deposit |
-------------------------
Notice that John made two operations in the last 3 minutes but it is considered only the last one.
Records in this table are ordered from the last to the older operation within 3-min timeslot.
May I show also a picture at the side of each operator’s name? (john.jpg, Simon.jpg…) in the php table generated from the query?
This query would do it.