Skip site navigation (1) Skip section navigation (2)

update order

From: uldis <uldis(at)motozurnals(dot)lv>
To: pgsql-novice(at)postgresql(dot)org
Subject: update order
Date: 2006-12-21 11:06:51
Message-ID: 458A6ACB.6040108@motozurnals.lv (view raw or flat)
Thread:
Lists: pgsql-novice
hello!

i am migrating from mysql to postgre and i have one little problem. i 
would like you to help me the best way to solve this pain...

so in mysql i had superious query:
select @i:=0;
update MyTable set OrderCol=(@i:=(at)i+1) order by OrderCol asc;

but in postgre is no way to update and order in same query. alos there 
is no user defined variables, bet i make one more sequence.

to resolve this problem i have to make selection ant then each resulting 
row with make a update. this is damn much queries! how to make it not so 
complex?

may be you can suggest me the best way to resolve this liitle problem?


thank you!

pgsql-novice by date

Next:From: NathanielDate: 2006-12-21 12:07:35
Subject: Using a serial primary key as a foreign key in a second table
Previous:From: Tom LaneDate: 2006-12-21 06:18:18
Subject: Re: print statements?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group