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.
| Author |
Topic |
|
shawnmolloy
Yak Posting Veteran
93 Posts |
Posted - 2007-08-09 : 01:17:44
|
| Hi,I'm building a shopping cart. I need help writing a query that gets a list of categories for a store. I want to get a result set that has all categories in order by their parent category. This is what the table looks like:Tbl_Category----------------ID (int)ParentID (int)CategoryName (varchar)I want to get a list of categories like this:Clothing (id: 5) (Parent Category) TShirts (id: 6) (Child) Mens shirts (id: 7) (child)In the table, the child categories have the top level category as the parent id, so the "Tshirt" parent_id is 5, and the "Mens shirts" parent_id is 6.I hope that makes sense...Thanks-- shawn |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2007-08-09 : 01:24:14
|
| Hi,for listing all the categories by their parent id. hope this is what you are looking for.. select categoryname, idfrom tbl_categoryorder by parentid |
 |
|
|
|
|
|