Is there other way in MySQL to achieve the same effect as query below without GROUP_CONCAT and SUBSTRING_INDEX trick?
How bad is this query when I have thousands of tickets per performance?
The point is to group tickets by performance, in these groups order tickets by status and select first ticket.id per group.
SELECT SUBSTRING_INDEX(GROUP_CONCAT(id ORDER BY status), ',', 1)
FROM ticket
GROUP BY performance_id
In other engines I would use something like this:
SELECT FIRST(t.id)
FROM (SELECT * FROM ticket ORDER BY status) AS t
GROUP BY performance_id
But MySQL doesn't have FIRST or related operator.