pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robby Slaughter <webmaster@robbyslaughter.com>
To: Fredrik Thunberg <fredrik@datessa.se>
To: pgsql-sql@postgresql.org
Subject: RE: Simple SQL-syntax
Date: Mon, 20 Aug 2001 09:55:47 -0500
Message-ID: <EPEHLKLEHAHLONFOKNHNMEPEDEAA.webmaster@robbyslaughter.com> (raw)
In-Reply-To: <01a501c12969$6e397a10$7100000a@intern.datessa.se>

Fredrik,

Just for future reference, it's generally a good idea to include a complete
table schema
and some sample data for your tables when asking this kind of question. But
I think I know
what you mean and will try to help you.

>Suppose I have Table A looking something like this:
>Index    Text    NrA

>And Table B like this:
>NrA    NrB

>Then I want to change all occurences of NrA in Table A to NrB...

First of all, your syntax isn't quite right. It's

   UPDATE tablename SET value = value WHERE [conditions];

There's no FROM clause in an update statement. And second, you
need to be careful to make sure all your tokens make sense. You
had an extra "B" in the middle of your statement. Based on this:

  UPDATE tableA,tableB SET tableA.NrA = tableB.NrB WHERE tableA.NrA =
tableB.NrB

should achieve the desired result.

Hope this helps!

-Robby Slaughter




view thread (8+ messages)  latest in thread

Message-ID: <EPEHLKLEHAHLONFOKNHNMEPEDEAA.webmaster@robbyslaughter.com>
Permalink:  ../EPEHLKLEHAHLONFOKNHNMEPEDEAA.webmaster@robbyslaughter.com/
Also on:    postgresql.org/message-id/EPEHLKLEHAHLONFOKNHNMEPEDEAA.webmaster@robbyslaughter.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: webmaster@robbyslaughter.com, fredrik@datessa.se
  Subject: RE: Simple SQL-syntax
  In-Reply-To: <EPEHLKLEHAHLONFOKNHNMEPEDEAA.webmaster@robbyslaughter.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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