Reputation: 2774
I need to update the DataEHoraInicialDoFeedback
column with the value from the DataEHoraInicial
column, where the DescricaoDoFeedback
is not empty (the field has no null values) and DataEHoraInicialDoFeedback
is null or DataEHoraInicialDoFeedback
is empty and StatusDoFeedback
has the value com Sucesso
UPDATE GestaoDeAlertas
SET GestaoDeAlertas.DataEHoraInicialDoFeedback = GestaoDeAlertas.DataEHoraInicial
WHERE EXISTS
(
SELECT *
FROM GestaoDeAlertas
WHERE DescricaoDoFeedback <> ''
AND (DataEHoraInicialDoFeedback IS NULL OR DataEHoraInicialDoFeedback= '')
AND StatusDoFeedback= 'com Sucesso'
)
In my tests (I have duplicated the table) the above update is updating all rows, as if it is ignoring the where clause.
Upvotes: 0
Views: 58
Reputation: 13344
Your query says:
If there is at least one row in the entire table that satisfies the specified condition, then do the update (regardless of the values in the current row).
I believe that Dan Bracuk
already gave you the right advice (see his comment): use direct WHERE
clause.
Upvotes: 1