Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Nesting Select statement in asp.net (vb)

Author  Topic 

goofy78270
Starting Member

4 Posts

Posted - 2011-12-13 : 15:10:13
Forgive me in advance if this is the wrong forum to post this.

I am just starting in my learning of vb.net and decided to create a shopping cart website to help in my learning. In doing this, I am having issues developing a select query for the asp:menu control that will nest items from my category table based on the subCatID.

Category Table structure
CatID - int - unique(pk)
Name - varchar(100)
SubCatID - (fk to CatID)

T-SQL Query
select child.Name, parent.Name
from CATEGORY child join CATEGORY parent
on child.SubCatID = parent.CatID
where child.SubCatID not null


Regards,
Mike

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-13 : 23:37:49
i think this is enough

select child.Name, parent.Name
from CATEGORY child join CATEGORY parent
on child.SubCatID = parent.CatID


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -