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 sb.publicada = 1 ORDER BY sb.id ASC' at line 1
SELECT sb.id, sb.nombre FROM subcategorias sb JOIN categorias c ON sb.categoria_id = c.id WHERE c.id = AND sb.publicada = 1 ORDER BY sb.id ASC