RE: Simple SQL-syntax

From: "Robby Slaughter" <webmaster(at)robbyslaughter(dot)com>
To: "Fredrik Thunberg" <fredrik(at)datessa(dot)se>, <pgsql-sql(at)postgresql(dot)org>
Subject: RE: Simple SQL-syntax
Date: 2001-08-20 14:55:47
Message-ID: EPEHLKLEHAHLONFOKNHNMEPEDEAA.webmaster@robbyslaughter.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-08-20 15:13:05 Re: Simple SQL-syntax
Previous Message Jean-Christophe Boggio 2001-08-20 14:51:33 Strange DISTINCT !