Unix Technical Forum

Order in the row!

This is a discussion on Order in the row! within the MySQL forums, part of the Database Server Software category; --> Hey guys, I'm new here and I hope its OK if I tap a lil into your knowledge base. ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 09:50 AM
Mohawk Mawk
 
Posts: n/a
Default Order in the row!

Hey guys,
I'm new here and I hope its OK if I tap a lil into your knowledge
base.

I have a table

ID|Name|Job


the ID is an int that auto increases and should stay the same for
history record.
Now I want to put order to the table.
Not by ID, not by name, not by job.
so I want to add a order collumn, but I'm not sure what values it
should have.
I want to list the names and decide to move them up or down in order.
e.g.

ID:1-Steve-Farmer (move up in order button)(move down in order button)
ID:2-Jim-Hunter (move up in order button)(move down in order
button)
ID:3-Al-Baker (move up in order button)(move down in order
button)

then if i click the (move up in order button) from Jim the list would
look like this

ID:2-Jim-Hunter (move up in order button)(move down in order
button)
ID:1-Steve-Farmer (move up in order button)(move down in order button)
ID:3-Al-Baker (move up in order button)(move down in order
button)

i hope you get the gist of what I want.
so what values should i use and how should they change to get the
effect I want? the list will probably be huge and its not really about
jobs and names but i just used this as an example.
Thanks for any ideas
Mawk

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 09:50 AM
subtenante
 
Posts: n/a
Default Re: Order in the row!

On 15 May 2007 01:15:28 -0700, Mohawk Mawk <blessblessbless@gmail.com>
wrote:

>Hey guys,
>I'm new here and I hope its OK if I tap a lil into your knowledge
>base.
>
>I have a table
>
>ID|Name|Job
>
>
>the ID is an int that auto increases and should stay the same for
>history record.
>Now I want to put order to the table.
>Not by ID, not by name, not by job.
>so I want to add a order collumn, but I'm not sure what values it
>should have.
>I want to list the names and decide to move them up or down in order.
>e.g.
>
>ID:1-Steve-Farmer (move up in order button)(move down in order button)
>ID:2-Jim-Hunter (move up in order button)(move down in order
>button)
>ID:3-Al-Baker (move up in order button)(move down in order
>button)
>
>then if i click the (move up in order button) from Jim the list would
>look like this
>
>ID:2-Jim-Hunter (move up in order button)(move down in order
>button)
>ID:1-Steve-Farmer (move up in order button)(move down in order button)
>ID:3-Al-Baker (move up in order button)(move down in order
>button)
>
>i hope you get the gist of what I want.
>so what values should i use and how should they change to get the
>effect I want? the list will probably be huge and its not really about
>jobs and names but i just used this as an example.
>Thanks for any ideas
>Mawk


You might need another field : parent, same type as your ID, and being
unique.
You also need a top-row with ID 0 or something of the kind you will
never change.

ID:0-EMPTY-EMPTY Parent:NULL
ID:1-Steve-Farmer Parent : 0
ID:2-Jim-Hunter Parent 1
ID:3-Al-Baker Parent 2

Then when you hit on Jim to put it up, you update Jim and Steve, to
have Jim having EMPTY as Parent, and Steve having Jim.

Then you SELECT everything again, and you always ORDER BY Parent.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 09:50 AM
strawberry
 
Posts: n/a
Default Re: Order in the row!

On May 15, 10:11 am, subtenante <zzsubtenant...@gmail.com> wrote:
> On 15 May 2007 01:15:28 -0700, Mohawk Mawk <blessblessbl...@gmail.com>
> wrote:
>
>
>
> >Hey guys,
> >I'm new here and I hope its OK if I tap a lil into your knowledge
> >base.

>
> >I have a table

>
> >ID|Name|Job

>
> >the ID is an int that auto increases and should stay the same for
> >history record.
> >Now I want to put order to the table.
> >Not by ID, not by name, not by job.
> >so I want to add a order collumn, but I'm not sure what values it
> >should have.
> >I want to list the names and decide to move them up or down in order.
> >e.g.

>
> >ID:1-Steve-Farmer (move up in order button)(move down in order button)
> >ID:2-Jim-Hunter (move up in order button)(move down in order
> >button)
> >ID:3-Al-Baker (move up in order button)(move down in order
> >button)

>
> >then if i click the (move up in order button) from Jim the list would
> >look like this

>
> >ID:2-Jim-Hunter (move up in order button)(move down in order
> >button)
> >ID:1-Steve-Farmer (move up in order button)(move down in order button)
> >ID:3-Al-Baker (move up in order button)(move down in order
> >button)

>
> >i hope you get the gist of what I want.
> >so what values should i use and how should they change to get the
> >effect I want? the list will probably be huge and its not really about
> >jobs and names but i just used this as an example.
> >Thanks for any ideas
> >Mawk

>
> You might need another field : parent, same type as your ID, and being
> unique.
> You also need a top-row with ID 0 or something of the kind you will
> never change.
>
> ID:0-EMPTY-EMPTY Parent:NULL
> ID:1-Steve-Farmer Parent : 0
> ID:2-Jim-Hunter Parent 1
> ID:3-Al-Baker Parent 2
>
> Then when you hit on Jim to put it up, you update Jim and Steve, to
> have Jim having EMPTY as Parent, and Steve having Jim.
>
> Then you SELECT everything again, and you always ORDER BY Parent.


http://www.phpriot.com/d/articles/cl...jax/index.html

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:12 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com