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

How do i do a count of how many records are tagged under one tag?

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
How do i do a count of how many records are tagged under one tag?

SELECT DISTINCT ut.uxtagid, ut.uuserid, ut.uprivate, tt.tid, tt.ttag, tt.trated FROM usertags ut, thetags tt WHERE ut.uuserid=1 AND ut.uxtagid=tt.tid ORDER by tt.ttag


"thetags" contains the actual tag name like this:

tid, ttag


"usertags" when a user tags a record its stored here, and the records here are linked to the tag name

uuserid = the user who tagged it
uxtagid = is joining the "thetag" table to identify the name of the tag
uxforumpostid = the record that is being tagged

Thanks for your help
Jason

Jason

[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]

 
The query i posted above displays all the tags for one user all i would like to do is count each record that is under each tag and display the number of records tagged next to it... so it would be like

tag (1)
tag (45)
tag (53)

Code:
[URL unfurl="true"]http://www.webreference.com/programming/javascript/ncz/column2/example2.html[/URL]



Jason

[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]
 
How about...

SELECT ttag, count(tid) FROM thetags
LEFT OUTER JOIN usertags on uxtagid=tid
WHERE uuserid=1 ORDER by ttag

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top