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 cur_master = 1 HAVING FIND_IN_SET('',unidade_rel) OR unidade_rel = 0' at line 4