RE: Simple SQL-syntax

Поиск
Список
Период
Сортировка
От Robby Slaughter
Тема RE: Simple SQL-syntax
Дата
Msg-id EPEHLKLEHAHLONFOKNHNMEPEDEAA.webmaster@robbyslaughter.com
обсуждение исходный текст
Ответ на Simple SQL-syntax  ("Fredrik Thunberg" <fredrik@datessa.se>)
Ответы Re: Simple SQL-syntax
Список 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



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: Simple SQL-syntax
Следующее
От: "Grigoriy G. Vovk"
Дата:
Сообщение: Re: Sequential select queries...??