pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
short sql question
2+ messages / 2 participants
[nested] [flat]

* short sql question
@ 2021-06-18 07:15 goldgraeber-werbetechnik@t-online.de
  2021-06-18 11:31 ` Re: short sql question Georg H. <georg-h@silentrunner.de>
  0 siblings, 1 reply; 2+ messages in thread

From: goldgraeber-werbetechnik@t-online.de @ 2021-06-18 07:15 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org


Hi,

I just cannot see what is wrong with my query:

create table files (id int, name text, prev_name text, ....);
create table fnchanged (id int, name text);

update files f set prev_name = f.name, name = c.name from fnchanges c where f.id = c.id and c.name != f.name

--- gets syntax error at "from"

(Using PostgreSQL 10.4 on a NAS box)

Best regards
Wolfgang







^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: short sql question
  2021-06-18 07:15 short sql question goldgraeber-werbetechnik@t-online.de
@ 2021-06-18 11:31 ` Georg H. <georg-h@silentrunner.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Georg H. @ 2021-06-18 11:31 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi,

Am 18.06.2021 um 09:15 schrieb goldgraeber-werbetechnik@t-online.de:
> Hi,
>
> I just cannot see what is wrong with my query:
>
> create table files (id int, name text, prev_name text, ....);
> create table fnchanged (id int, name text);
>
> update files f set prev_name = f.name, name = c.name from fnchanges c where f.id = c.id and c.name != f.name

your update statement works for me after changing

from fnchanges

   to

from fnchanged
(as written in your create statement) but I've gotERROR: relation "fnchanges" does not exist instead of a syntax error

>
> --- gets syntax error at "from"
>
> (Using PostgreSQL 10.4 on a NAS box)
>
> Best regards
> Wolfgang
>
kind regards
Georg

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-06-18 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 07:15 short sql question goldgraeber-werbetechnik@t-online.de
2021-06-18 11:31 ` Georg H. <georg-h@silentrunner.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox