Re: Threaded Records in SQL: Advice Needed

From: "tjk(at)tksoft(dot)com" <tjk(at)tksoft(dot)com>
To: BIngram(at)sixtyfootspider(dot)com (Ingram Bryan)
Cc: mig(at)utdt(dot)edu, pgsql-sql(at)postgresql(dot)org
Subject: Re: Threaded Records in SQL: Advice Needed
Date: 2000-04-11 22:32:39
Message-ID: 200004112232.PAA23653@uno.tksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bryan,

You can numerically, even if the field is a text field,
if all fields have a number.

Just cst to an int4.

E.g.

create table testtable (num text, num2 text);

select num from testtable order by num::int4;

Troy

>
> Thanks for the ideas on the functions, that'll work nicely.
>
> The only other problem I see in actually implementing this, is that the id
> column i.e. /25/10/2/ will not be ordered correctly because it relies on
> ascii values. You get alphabetic orderings, rather than numerical.
>
> Such as:
>
> 1
> 10
> 11
> 12
> 14
> 2
> 20
> 25
> 3
> 4
> 5
>
> instead of
>
> 1
> 2
> 3
> 4
> 5
> 10
> 11
> 12
> 14
> 20
> 25
>
> Any ideas how to get around this? I'm working on the problem right now, but
> haven't found anything yet.
>
> Bryan
>
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Raul Chirea 2000-04-12 02:49:44 Foreign keys breaks tables permissions
Previous Message Michael McCarthy 2000-04-11 22:10:04 RE: Threaded Records in SQL: Advice Needed