Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Items from a 1-to-many view/query 2

Status
Not open for further replies.

DSect

Programmer
Sep 3, 2001
191
US
Hello -

I have a query that returns records from 2 tables. I want to display the rows in an orderly fasion using ASP.

The two tables: tblSchools, tblDepts

1 school can have many depts.

So my query results look like this after displaying them after looping:

AARDVARK COLLEGE (school name)
DEPT OF FOOD (dept for AARDVARK)
AARDVARK COLLEGE (school name)
DEPT OF MATH (2nd dept for AARDVARK)

The problem is that when there is more than one DEPT for a school, the school name is repeated, obviously.

My question is how to remove the repeated school lines in my viewing page?

I know I can do it at runtime in the ASP code by comparing the SCHOOL NAME and hiding it if it matches the last, next etc.

Should I do something different with my query to make the shape of the data diffnt?

Like I said, I can do it with ASP code and that's what I'd do, but I feel like it's the long way to do it.

Let me know if you have any other ways to hide these repeated rows, other than using ASP to look at the current school name and taking action based on the comparision.

Thanks for the help as always!
 
I have done this several times before and always end up doing it with ASP as you mention - comparing the value to the previous value and only displaying it if they differ.

Not seen it done any other way Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Assuming your query returns a resultset something like this:

School | Dept
SchoolA | Food
SchoolA | Maths
SchoolB | IT
SchoolB | Maths
...

then I would do what you say and use the ASP to format the page output. There's no way to use the query that would make it any easier for you.

It should be quite simple to keep the current school in a variable while looping and only print the school name if it differs. Let us know if you need help with this part. --James
 
Hey guys! Thanks for the reassurance.

I will do it with ASP, like I was planning on.

I just wanted to check to see if there is any other way to do it before I code it.

Thanks again for the prompt responses. This question has been answered.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top