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('5',unidade_rel) OR unidade_rel...' at line 4