UPDATE command with FROM clause - Mailing list pgsql-sql

From JORGE MALDONADO
Subject UPDATE command with FROM clause
Date
Msg-id CAAY=A7-UcNWsakeEALHfdZMQ_0qZaBFbY+JM+qF1_mnCX-ckaw@mail.gmail.com
Whole thread Raw
Responses Re: UPDATE command with FROM clause  (Rob Sargent <robjsargent@gmail.com>)
Re: UPDATE command with FROM clause  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-sql
Hi,

I have a query like this:

UPDATE chartsclub.secc_esp_votar_votos
SET svv_puntos = 0 FROM
(SELECT * FROM chartsclub.secc_esp_votar_votos AS tblVotos WHERE svv_sva_clave = 114 EXCEPT
       (SELECT DISTINCT ON (svv_fechareg) * FROM chartsclub.secc_esp_votar_votos AS tblVotos WHERE svv_sva_clave = 114 ORDER BY svv_fechareg))

Will the UPDATE command affect only (all) records generated by the SELECT clause in the FROM clause?

I suppose that, if I include a WHERE clause, the condition will be applied to the records obtained by the SELECT clause in the FROM clause. 
Is this correct?

My goal is to get a set of records from one table and update only such a set of records.
In this case, the set of records to be updated are those obtained by the SELECT command in the FROM clause.
As you can see, there is only one table involved but I added an alias to the SELECT statement in the FROM clause based on what I read in the documentation.

Best regards,
Jorge Maldonado

Libre de virus. www.avast.com

pgsql-sql by date:

Previous
From: Rajesh Parameswaran
Date:
Subject: [ECPG] - Help on Dynamic Query using SQLDA with Cursors
Next
From: Rob Sargent
Date:
Subject: Re: UPDATE command with FROM clause