SELECT e.id
FROM event AS e
INNER JOIN event_participants AS ep ON e.id = ep.eventFK
LEFT JOIN participant AS p ON ep.participantFK = p.id
WHERE p.id =
AND e.status_type = 'finished'
ORDER BY e.startdate DESC
LIMIT 6 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND e.status_type = 'finished'
ORDER BY e.startdate DESC
' at line 8