SELECT *,IF(SUBSTRING(autor,1,1)='',CONCAT('L',autor), IF(SUBSTRING(autor,1,1)='',CONCAT('S',autor), IF(SUBSTRING(autor,1,1)='',CONCAT('C',autor), IF(SUBSTRING(autor,1,2)='( ',SUBSTRING(autor,3,6), IF(SUBSTRING(autor,1,1)='(',SUBSTRING(autor,2,5), IF(SUBSTRING(TRIM(autor),1,1)='',IF(SUBSTRING(TRIM(tytul),1,1)='(',SUBSTRING(tytul,2,8),tytul),autor ) ) ) ) ) ) AS order_arg FROM oferta WHERE id IN () ORDER by order_arg LIMIT 250,50
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 ') ORDER by order_arg LIMIT 250,50' at line 7