943,871 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Marked Solved
  • Views: 9355
  • ASP RSS
You are currently viewing page 9 of this multi-page discussion thread; Jump to the first page
Feb 15th, 2008
0

Re: Nested loop

MAN you are absoluteley right.

As talked about before (GROUP BY) cluse was set to top category. I deleted that one and VOILA

Hang on


CHECK THE ATTACH - IT IS NOT A FAKE IT'S FOR REAL
Attached Thumbnails
Click image for larger version

Name:	table_12.jpg
Views:	17
Size:	165.2 KB
ID:	5104  
Last edited by TobbeK; Feb 15th, 2008 at 3:41 pm.
Reputation Points: 10
Solved Threads: 3
Junior Poster
TobbeK is offline Offline
190 posts
since Feb 2008
Feb 15th, 2008
0

Re: Nested loop

Oh okay that's how you have it set. Yeah that is fine. Not highly recommended, but it works. Okay then try this query:
ASP Syntax (Toggle Plain Text)
  1. SQL = "SELECT TC.topcategory, MC.middlecategory "&_
  2. "FROM tbtopcategory TC, tbmiddlecategory MC, tbconnectcategory CC "&_
  3. "WHERE TC.topcategoryID = CC.topcategorylink "&_
  4. "AND MC.tbmiddlecategoryID = CC.middlecategorylink " &_
  5. "GROUP BY TC.topcategory "
You have to lost the DISTINCT, otherwise you will only grab One Top Category, which means you only grab one MiddleCategory. Drop the destinct, and no need for the MCLink.

And now your thing should work.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Feb 15th, 2008
0

Re: Nested loop

NO NO, you have to keep GROUP BY clause in there, if you don't, your records won't go in the right places, and you'll have duplicate columns!

You just need to lose the DISTINCT. DISTINCT grabs only the unique ones. So if you have 10 TopCats named NameMyTopCat, it will only pull 1. Since it only pulls 1, it will only pull one MiddleCat. That's where you failed.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Feb 15th, 2008
0

Re: Nested loop

Yes this was the right one, added middlecat as well to GROUP BY and it is working

SQL = "SELECT TC.topcategory, MC.middlecategory "&_
"FROM tbtopcategory TC, tbmiddlecategory MC, tbconnectcategory CC "&_
"WHERE TC.topcategoryID = CC.topcategorylink "&_
"AND MC.tbmiddlecategoryID = CC.middlecategorylink " &_
"GROUP BY TC.topcategory ASC, MC.middlecategory ASC"
set RS = Server.CreateObject("ADODB.recordset")
Reputation Points: 10
Solved Threads: 3
Junior Poster
TobbeK is offline Offline
190 posts
since Feb 2008
Feb 15th, 2008
1

Re: Nested loop

You probably don't even need middlecategory. If you wish, you should do it this way:
ASP Syntax (Toggle Plain Text)
  1. SQL = "SELECT TC.topcategory, DISTINCT(MC.middlecategory) "&_
  2. "FROM tbtopcategory TC, tbmiddlecategory MC, tbconnectcategory CC "&_
  3. "WHERE TC.topcategoryID = CC.topcategorylink "&_
  4. "AND MC.tbmiddlecategoryID = CC.middlecategorylink " &_
  5. "GROUP BY TC.topcategory"

This way it will grab only the unique sub names (which you don't want duplicates of anyway). No need for group by, as when you have uniques, grouping 1, 2, 3 will turn out as 1, 2, 3. It's pointless.

Glad to see its working. Show me?
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Feb 15th, 2008
0

Re: Nested loop

I don't how to thank you enough for the most valued and professional help any can ever get on any forum.
Reputation Points: 10
Solved Threads: 3
Junior Poster
TobbeK is offline Offline
190 posts
since Feb 2008
Feb 15th, 2008
0

Re: Nested loop

This is the output (before I prints it out and hang it in some golden frame)



You probably don't even need middlecategory. If you wish, you should do it this way:
ASP Syntax (Toggle Plain Text)
  1. SQL = "SELECT TC.topcategory, DISTINCT(MC.middlecategory) "&_
  2. "FROM tbtopcategory TC, tbmiddlecategory MC, tbconnectcategory CC "&_
  3. "WHERE TC.topcategoryID = CC.topcategorylink "&_
  4. "AND MC.tbmiddlecategoryID = CC.middlecategorylink " &_
  5. "GROUP BY TC.topcategory"

This way it will grab only the unique sub names (which you don't want duplicates of anyway). No need for group by, as when you have uniques, grouping 1, 2, 3 will turn out as 1, 2, 3. It's pointless.

Glad to see its working. Show me?
Attached Thumbnails
Click image for larger version

Name:	table_12.jpg
Views:	15
Size:	165.2 KB
ID:	5105  
Reputation Points: 10
Solved Threads: 3
Junior Poster
TobbeK is offline Offline
190 posts
since Feb 2008
Feb 15th, 2008
0

Re: Nested loop

Next time, remind me to look at the query first lol.

You're welcome.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Feb 15th, 2008
0

Re: Nested loop

Dont hesitate to contact me if there is anything I can do for help. I will be here now and then.

Again thanks and many greetings from Stockholm

sincerely
Torbjorn
Last edited by TobbeK; Feb 15th, 2008 at 4:07 pm.
Reputation Points: 10
Solved Threads: 3
Junior Poster
TobbeK is offline Offline
190 posts
since Feb 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Help: passing variable via table field different page subroutine
Next Thread in ASP Forum Timeline: count words or characters in strings advice needed





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC