main
Johnathan Douglas 2023-07-10 09:27:03 -03:00
parent 889ee979bf
commit cf39df489a
1 changed files with 3 additions and 4 deletions

View File

@ -73,7 +73,7 @@ where id in (1, 2, 3, . . .);
### Grupo 2:
Atualizar um campo ou mais, mas o valor é o `diferente` para um determinado grupo:
Atualizar um campo ou mais, mas o valor é o `diferente` para cada registro:
`Update3Job`
@ -92,19 +92,18 @@ update transactions
set date='2023-04-03',
value=30
where id = 3;
...
```
`Update4Job`
```sql
update transactions
set date= case id when 1 then '2023-04-01'::date
set date = case id when 1 then '2023-04-01'::date
when 2 then '2023-04-02'::date
when 3 then '2023-04-03'::date
end
,
value=case id when 1 then 10
value = case id when 1 then 10
when 2 then 20
when 3 then 30
end