dynamic grouping

how can i create a group by query  where from my database automatically it will display on page  all categories and subcategories  based on the information in my tables

for instance something like this

Forms
  form a
  form b

News
  news a
  news b

Links
  links a
  link b

and my table looks like this

departments

departmentid|  departmentname

Categories

categorieid|departmentid| categoriename

Subcategories

subcategorieid| categorieID | Subcategorieinfo


is there is a solution that creates this please send me a link to evaluate.

thanks
LVL 1
gianitooAsked:
Who is Participating?
 
Brian CroweDatabase AdministratorCommented:
would this work for you?

SELECT departments.*, categories.*, subcategories.*
FROM departments
INNER JOIN categories
     ON departments.departmentid = categories.departmentid
INNER JOIN subcategories
     ON categories.categoryid = subcategories.categoryid
ORDER BY departments.departmentname, categories.categoryname, subcategories.subcategoryinfo
0
 
gianitooAuthor Commented:
do you see how in crystal reports you can group by a categorie and automatically tab the subcategories

for example:

Food
    apple
    tomatos

Clothes
   jacket
   tshirt

and lets say that i add another categorie called cars with 2 subcategories and utomatically gets added as seen below

Food
    apple
    tomatos

Clothes
   jacket
   tshirt

Cars
  Porshe
  Mazda

do i make sense?

i know how to do this but by writing multiple queries for each categorie.   it nees to be done dinamically to eliminate worktime
   
0
 
gianitooAuthor Commented:
this is an example

http://www.sharepointcustomization.com/finance/default.aspx

view the finance team categorie
0
 
Brian CroweDatabase AdministratorCommented:
I believe in the case example you are providing that they are using a version of a datagrid with a related child table.  The example I provided is how I would solve the problem in Crystal.
0
 
gianitooAuthor Commented:
ok thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.