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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with left join + count 1

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
I have a categories table and a tutorials table, I would like to left join the tutorials to count them, I must check to see if the tutorial is in cat1 & cat2, I do realise i need a GROUP by however I still can't get it to work with a group by...

Any suggestions would be greatly appreciated.


Code:
	sql = "Select cat.cid, cat.cname, cat.ctype, tut.tcat, COUNT(tut.tsubcat) as CategoryCount "_
	& "FROM categories cat LEFT join tutorials tut on tut.tcat=" & cid & " AND tut.tsubcat=cat.cid WHERE cat.ctype=3 ORDER BY cat.cname ASC"
 
It's not very clear what you're trying to do. Can you elaborate a bit?
 
I am looping through categories

Category1
SubCategory1.1 (xxx number of tutorials)
SubCategory1.2 (xxx number of tutorials)
Category2
SubCategory2.1 (xxx number of tutorials)
SubCategory2.2 (xxx number of tutorials)

etc...

There is tutorials under these sub categories the above sql statement in being used inside the loop of the main categories, to write out the sub categories. I would like to count the tutorials that are in category1 and SubCategory1.1 and output the ammount of tutorials under that category1 & subcategory next to it... I hope you can understand this, cause I can't explain it to well...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top