Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My Table is-:
Category fields are-:
CategoryID, Category_Name, Category_Description
1 Science aaaaa
2 Language lllll

SubCategory fields are-:
SubCategoryID, CategoryID, SubCategory_Name, SubCategory_Description
1 1 Physics pppppppppp
2 1 Science ssssssssss
3 2 Hindi hhhh
4 2 English eeeeee
5 2 Maths mmmmmm



I want to result below in dropdown list-

Science(it is category_Name)
--Physics(it is subcategory_Name)
--Biology(it is subcategory_Name)
Langauge(it is category_Name)
--Hindi(it is subcategory_Name)
--English(it is subcategory_Name)
--Maths(it is subcategory_Name)
Posted
Updated 19-May-14 2:18am
v2

1 solution

hi,

Check this query :

SQL
Select q.CategoryID,q.SubCategoryID,q.Category_Name
FROM
(
Select CategoryID,0 as SubCategoryID,Category_Name
from Category 
Union ALL
Select  CategoryID,SubCategoryID,SubCategory_Name as Category_Name
from SubCategory 
) q
order by q.CategoryID,q.SubCategoryID,q.Category_Name

Note i just used the select query you can apply your where conditions if needed
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900