Question

CAKAta on Wed, 12 Feb 2014 11:34:04


Hi, I want to populate all cells in any row. For example I will draw you the table.

ID|Name------|Parent|ORDERNUM
1---PEOPLE-----0
2---Arm----------1
3---FISH---------0
4---Fin-----------3
5---Legs---------1

I want to fill last column ORDERNUM with numbers from 0 to last row (5000)

But I want to fill it with special method. I want to fill it like this WRONG code( because I don`t know how is right :))

"UPDATE Table_Name SET ORDERNUM = (0, 1) WHERE ORDER BY Parent ASC"

If anyone could help me with RIGHT code pls WRITE it.

Thanks Bye!


Sponsored



Replies

Olaf Helper on Wed, 12 Feb 2014 11:44:46


Not sure, if I got you right; a continously number in order by "Parent", like here NewValue in this query:

SELECT *
      ,ROW_NUMBER() OVER (ORDER BY Parent) AS NewValue
FROM Table_Name
ORDER BY Parent ASC

Visakh16 on Wed, 12 Feb 2014 12:22:42


can you explain the rules for getting those values? how did you get 3 for Fin, 1 for Legs etc?

CAKAta on Thu, 13 Feb 2014 08:51:29


I made 1 treeList Parent = ID on parent Node in list. And I wanted to fill last column ORDERNUM with numbers drom 0 to 5000 but fist I need to order by Parent value and then to fill ORDERNUM with numbers 1-5000.

Only then Indexes in TreeList will  be = on ORDERNUM. After that I can drag and drop nodes and saved on right place in DB.

I made this thanks!