UPDATE WITH ORDER BY

From: Rodrigo Carvalhaes <grupos(at)carvalhaes(dot)net>
To:
Cc: pgsql-sql(at)postgresql(dot)org
Subject: UPDATE WITH ORDER BY
Date: 2005-04-26 03:12:32
Message-ID: 426DB1A0.2000604@carvalhaes.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<div class="moz-text-html" lang="x-western">
<tt>Hi Guys!<br>
<br>
I need to make an UPDATE on a column reordering it with a sequence
using order by a description.<br>
Confusing??? Well.. Let me give an example...<br>
<br>
Today, my table it's organized like this:<br>
<br>
Code&nbsp;&nbsp;&nbsp;&nbsp; / Description<br>
9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Orange<br>
15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Apple<br>
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pear<br>
3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tomato<br>
<br>
I wanna to reorganize (reordering the code from 1 to ... ordering by
description)<br>
</tt><tt><br>
Code&nbsp;&nbsp;&nbsp;&nbsp; / Description<br>
</tt><tt>1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Apple</tt><br>
<tt>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Orange<br>
3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pear<br>
4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tomato</tt><br>
<tt><br>
I created a sequence but I am having no succes to use it because UPDATE
don't accept ORDER BY CLAUSE. The "ideal SQL" is UPDATE table SET code
= nextval('sequence') ORDER BY description <br>
<br>
I searched a lot on the NET without ant "tip" for my case. <br>
It's a very simple need but I am not able to solve it...<br>
<br>
Anyone knows how I can do it?<br>
<br>
Cheers,<br>
<br>
-- <br>
Rodrigo Carvalhaes<br>
<br>
</tt><!-- |**|end egp html banner|**| -->
</div>
</body>
<br />--
<br />Esta mensagem foi verificada pelo sistema de antivírus e
<br /> acredita-se estar livre de perigo.
</html>

Attachment Content-Type Size
unknown_filename text/html 1.8 KB

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ramakrishnan Muralidharan 2005-04-26 04:28:05 Re: people who buy A, also buy C, D, E
Previous Message Dan Langille 2005-04-26 02:21:35 people who buy A, also buy C, D, E