You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER by CASE WHEN t2.turnierstatus=3 THEN t2.turnierstatus END ASC, CASE WHEN t' at line 1