469,610 Members | 2,081 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

sql trees move some element

hi

I have a table:
id | integer | not null default
nextval('public.menu_2_id_seq'::text)
parent_id | integer |
description | text | not null

how am I able to move some element with id = x before or after
element with id = y ?

--
WBR, sector119

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #1
1 1446
> I have a table:
id | integer | not null default
nextval('public.menu_2_id_seq'::text)
parent_id | integer |
description | text | not null

how am I able to move some element with id = x before or after
element with id = y ?

In relational databases there is no such concept of "before"
and "after". If you want to make id.x smaller then id.y you
can just update the column id to the values you desire. You
then need to make sure that you don't get in the way of the id
value of other rows. One way to do it would be to compare the
values of id.x and id.y and switch them around if necessary.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Lothar Scholz | last post: by
1 post views Thread by Aleksi Kallio | last post: by
5 posts views Thread by bugbear | last post: by
reply views Thread by Sergei Levchenko | last post: by
7 posts views Thread by jefftyzzer | last post: by
7 posts views Thread by Vinodh | last post: by
8 posts views Thread by Bert | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.