473,473 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL - a menu system - plz help

Hi,

As subj says. A simple menu is defined in a table. But how to extract it?
Heres the deal:

Table menu has these 3 columns: menuid parent menudesc

Ok this should be easy right? Those menu-rows that has parent=0 is
"toplevel". And so forth. An example:

1 0 "Items"
2 0 "Standings"
3 0 "Test"
4 2 "Liverpool"
5 2 "AC Milan"
6 1 "Itemno1"

This menu should in layout come in this order:

Items
Itemno1
Test
Standings
AC Milan
Liverpool

That is: Alphabetically sorted and with the children underneath the parents.
Right? Yes - and selecting the menu and doing some gymnastics in ASP isnt
that hard. But ASP must be the language that has the "crapiest" way of
handling arrays...so a simple task is really messy. Creating a stored
procedure involes 2-3 temporary tables as I see it. Not vey elegant either.

So my question is: Isnt there any way of selecting this order directly using
SQL?? Some nice clean and beautiful way?

--
Thanks,
Summa
Jul 20 '05 #1
2 1504
Hi

Have you thought of using XML for this?

http://sqlxml.org/faqs.aspx?faq=53

You may also want to search Google for hierarchy and SQLServer

If you want a permanent reference you can try the following books:
Advanced Transact-SQL for SQL Server 2000 by Itzik Ben-Gan and Tom Moreau.
The book has an entire chapter on modeling a hierarchical structure in SQL
Server, along with T-SQL to implement the same.

SQL for Smarties by Joe Celko. This has an alternative method of modeling
trees in an RDBMS.

John

"Summasummarum" <Su***********@hotmail.com> wrote in message
news:3f*********************@dtext02.news.tele.dk. ..
Hi,

As subj says. A simple menu is defined in a table. But how to extract it?
Heres the deal:

Table menu has these 3 columns: menuid parent menudesc

Ok this should be easy right? Those menu-rows that has parent=0 is
"toplevel". And so forth. An example:

1 0 "Items"
2 0 "Standings"
3 0 "Test"
4 2 "Liverpool"
5 2 "AC Milan"
6 1 "Itemno1"

This menu should in layout come in this order:

Items
Itemno1
Test
Standings
AC Milan
Liverpool

That is: Alphabetically sorted and with the children underneath the parents. Right? Yes - and selecting the menu and doing some gymnastics in ASP isnt
that hard. But ASP must be the language that has the "crapiest" way of
handling arrays...so a simple task is really messy. Creating a stored
procedure involes 2-3 temporary tables as I see it. Not vey elegant either.
So my question is: Isnt there any way of selecting this order directly using SQL?? Some nice clean and beautiful way?

--
Thanks,
Summa

Jul 20 '05 #2
John Bell wrote:
Hi

Have you thought of using XML for this?

http://sqlxml.org/faqs.aspx?faq=53

You may also want to search Google for hierarchy and SQLServer


Very nice links...thatnks.

/Summa
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
2
by: Peter Proost | last post by:
Hi, I've got the following ownerdraw menu: drag a mainmenu on a form and add some menuitems to it, set all the menuitems to ownerdraw = true and for every menuitem add this code (replace...
4
by: Bob Homes | last post by:
In VB6, I used a system, which I loved, whereby I assigned a "helpId" to each menu item; that way, you could rest the cursor on the item (without actually running it) and then press F1 to get...
3
by: John | last post by:
Hi there, I was reading an article (http://avenuea-razorfish.com/articles/TheAll-MenuNavigation_Turbek.pdf) on 'all-menu navigation' and I'd like to try and implement this in my site. Can...
0
by: Patel | last post by:
Hi All, I am doing one INTERESTING work with Context Menu Strip. I am trying to insert a custom control / .Net control in Context menu as a context menu strip. I tried inserting MonthCalender in...
1
by: Preeti | last post by:
Hi all I am a fresher and have been given a requirement in VB.net I have to make an application in VB.net which will run as a system tray icon and will add one or two items in the default...
1
by: bruce628 | last post by:
I want to use SWT Label and popmenu to construct a menubar ,and the effect of this menubar is same to the menubar in SWT.When click the Label,it should be highlighted and popmenu shows.The issue is...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.