If I understood your question correctly, it would be something like this:
UPDATE Tabla1
SET GrupoAnexado = CASE WHEN GrupoId3 IS NULL THEN 'x' ELSE GrupoAnexado END,
GrupoId3 = CASE WHEN GrupoId3 IS NOT NULL THEN 'x' ELSE GrupoId3 END
WHERE MiCampo = 'Condiciones'
The condition to update each field will depend on GrupoId3
( NULL
or NOT NULL
), with the CASE
we verify this and in one case we establish the value and in another we let it be the same field. The only issue that must be taken into account is: if you eventually have a trigger that verifies the UPDATE
of some of these columns to do something, this would also be executed if you are updating it with the same value that you already have. If this were the case, to avoid it, there is no choice but to run the two sentences separately:
UPDATE Tabla1
SET GrupoAnexado = 'X'
WHERE MiCampo = 'Condiciones'
AND GrupoId3 IS NULL
UPDATE Tabla1
SET GrupoId3 = 'X'
WHERE MiCampo = 'Condiciones'
AND GrupoId3 IS NOT NULL