SELECT
                id,
                sortierung,
                feld_211,
                feld_217,
                feld_219,
                feld_2110,
                feld_2119
            FROM kr_fps_daten_modul_21
            WHERE
                mutter_id = 0
                AND
                feld_2119 = 
                AND
                (
                sortierung = IFNULL((
                    SELECT min(sortierung) FROM kr_fps_daten_modul_21 WHERE feld_2119 =  AND sortierung > ),0)
                OR
                sortierung = IFNULL((
                    SELECT max(sortierung) FROM kr_fps_daten_modul_21 WHERE feld_2119 =  AND sortierung < ),0)
            )
        
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 'AND
                (
                sortierung = IFNULL((
                    ' at line 14