Re: Select into
От | Gurjeet Singh |
---|---|
Тема | Re: Select into |
Дата | |
Msg-id | 65937bea0803200613k4593da12hd62233f8a745309@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Select into (Joe <dev@freedomcircle.net>) |
Ответы |
Re: Select into
Re: Select into |
Список | pgsql-sql |
On Thu, Mar 20, 2008 at 5:40 PM, Joe <dev@freedomcircle.net> wrote:
Except that it doesn't work... Did you try to execute that query; I am assuming not.
Best regards,
--
gurjeet[.singh]@EnterpriseDB.com
singh.gurjeet@{ gmail | hotmail | indiatimes | yahoo }.com
EnterpriseDB http://www.enterprisedb.com
17° 29' 34.37"N, 78° 30' 59.76"E - Hyderabad *
18° 32' 57.25"N, 73° 56' 25.42"E - Pune
37° 47' 19.72"N, 122° 24' 1.69" W - San Francisco
http://gurjeet.frihost.net
Mail sent from my BlackLaptop device
Gavin 'Beau' Baumanis wrote:I think what you want is something like this:
>
> The copy is inside the same table, so I don't understand why it (the
> required query ) would require any joins.
>
> Ie. I want to copy the contents of a row (but for the id column - of
> course) into a record in the same table.
Given (col1 being the id or PK):
col1 | col2 | col3
------+------+---------------
1 | 123 | first record
2 | 456 | second record
3 | 789 | third record
then
update t1 set col2 = t1copy.col2, col3 = t1copy.col3
from t1 as t1copy
where t1.col1 = 1 and t1copy.col1 = 3;
will result in:
col1 | col2 | col3
------+------+---------------
1 | 789 | third record
2 | 456 | second record
3 | 789 | third record
So, it is a join ... of a table with a virtual copy of itself.
Except that it doesn't work... Did you try to execute that query; I am assuming not.
Best regards,
--
gurjeet[.singh]@EnterpriseDB.com
singh.gurjeet@{ gmail | hotmail | indiatimes | yahoo }.com
EnterpriseDB http://www.enterprisedb.com
17° 29' 34.37"N, 78° 30' 59.76"E - Hyderabad *
18° 32' 57.25"N, 73° 56' 25.42"E - Pune
37° 47' 19.72"N, 122° 24' 1.69" W - San Francisco
http://gurjeet.frihost.net
Mail sent from my BlackLaptop device
В списке pgsql-sql по дате отправления: