ok, kind of finding it hard to give this question a proper title as im not really sure what you would call this function.
So, i have a table called categories, it contains ID, ParentID, Name, OrderNo plus a few more.
What i want to do is Give each category an OrderNo, by order number i mean if my category tree is as follows:
Computers
Computers > Laptops
Computers > Desktops
Computers > Components > Hard Drives
Computers > Components > Monitors
TVs
TVs > LED
TVs > LCD
So i simply want to give each category a value for OrderNo that starts from 1. So
Computers 1
Computers > Laptops 1
Computers > Desktops 2
Computers > Components 3
Computers > Components > Hard Drives 1
Computers > Components > Monitors 2
TVs 2
TVs > LED 1
TVs > LCD 2
Hopefully this makes more sense that it does trying to explain what i am trying to do. Unfortunatly i have no idea what such a function would be called, else i would google it.
My initial select statement would look something like:
select ID,ParentID,Name,OrderNo
from categories
Order by ParentID,ID
But no idea how to advance it further. Sorry for the rubbish explanation Thanks in advance John