Search Postgresql Archives

Renumber table rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.
 
I have a table that his primary key is not ordered is something like this:
 
1      - a
12    - b
123  - c
etc.
 
I want to do an update to make it like this
 
1 – a
2 – b
3 – c
 
I tried this:
 
UPDATE operador SET idoperador=(SELECT row_number() OVER (ORDER BY idoperador) from operador)
 
But it returns this error: more than one row returned by a subquery used as an _expression_ and I know that is because the substring returns more than one row, but how can I use the subquery to perform the update?.
 
Thank you in advance
 

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux