I have tbl_ocorrencias
that records occurrences of a particular vehicle. That is, the table consists of the following:
- tbl_ocorrencias -
id_ocorrencia
id_viatura
data
hora
In this case, an instance only has one vehicle but a vehicle can have multiple occurrences.
What I want is in the following image:
What's in the image is this:
- I can only fetch the last 3 occurrences of a given
id_viatura
- Each occurrence found is listed in a forward column as it appears in the image
For this I am trying to do in php and mysql but I am not able to come up with a solution.