Here is a structure of my tables:
![Tables structure](https://i.stack.imgur.com/KfLbn.png)

Here is what I want as a result of a query (considering that user provides me with `2|4|1` pattern):
![Result of a query](https://i.stack.imgur.com/Z1OxO.jpg)

Here is what I tried:

```
SELECT parcel.TrackCode, parcelType.Name, GROUP_CONCAT(track.DateTime SEPARATOR '|') AS dt
FROM track
JOIN parcel ON track.ParcelID = parcel.ID
JOIN parcelType ON parcel.ParcelTypeID = parcelType.ID
JOIN event ON track.EventID = event.ID
GROUP BY parcel.ID;

```

The result is:

![Result](https://i.stack.imgur.com/R81jc.png)

So the problem is that I need GROUP\_CONCAT() to divide data to several fields (`date where track.eventID = 3`, `date where track.eventID = 1`, `date where track.eventID = 5`, `date where track.eventID = 7` # considering that the pattern is `3|1|5|7`). Any ideas?