Re: Query on a sorted list (recursive/unary relationship)

From: Michael Fuchs <fuze-YOUKNOWWHATTODOWITHTIHS-_at_gmx.net>
Date: Sun, 06 Jun 2004 21:24:16 +0200
Message-ID: <c9vqkc$467$1_at_bird.wu-wien.ac.at>


Alan wrote:
> Use the ORDER BY clause.

OK, but ORDER BY what?
ORDER BY ParentID gives _not_ the korrekt order.

|----|----------|

| ID | ParentID |
|----|----------|
| 1 | NULL |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
| 5 | 4 |
| 6 | 5 |
|----|----------| now I want switch the IDs 3 and 4 |----|----------|
| ID | ParentID |
|----|----------|
| 1 | NULL |
| 2 | 1 |
| 4 | 2 |
| 3 | 4 |
| 5 | 3 |
| 6 | 5 |

|----|----------|

This now is the order I want to get. Looking at the two colums makes it obvious that I can not use the ORDER BY clause on them.

I guess there is no way other than programming the right order in the application.

Thank you,
Michael Received on Sun Jun 06 2004 - 21:24:16 CEST

Original text of this message