please forgive my SQL ignorance... i'm trying to learn. :-)
i have a site where people sign up for a profile, and in their profile they input their Blog URL and select a neighborhood to identify with.
From there, the site has a list of the neighborhoods in my city, and each neighborhood has a number next to it... the # of blogs in that neighborhood. (you click on the neighborhood link, and it displays the list of blogs, etc.) My neighborhood blog list needs to show up like this:
Egan Park: 3
Five Points: 12
Vinings: 9
etc, etc.
My neighborhoods are set up as category terms (stored in "term_data")...
tid, vid, name
142, 4, Egan Park
and here's the table for "profile_values"....
fid, vid, value
22, 6, s:3:"142";
How do i join these and count the # of blogs per neighborhood?
Here is what i have, and it's not working... the $result3 part works fine... it will give me the list of 'hoods... but the $sql3 part is where i need help Counting and Joining :-)
Also, if anyone could explain what "n" and "tn" and "%s" and "%d" means, that would rock. I can't find the info on here anywhere.
<?php
$vocabulary_id = 4;
$result3 = db_query("SELECT d.tid, d.name FROM {term_data} d WHERE d.vid = $vocabulary_id GROUP BY d.tid, d.name ORDER BY d.name");
$items = array();
$sql3 = "SELECT COUNT (n.fid) AS count FROM {profile_values} tn INNER JOIN {term_data} n USING (tid) WHERE tn.tid AND n.value = '%d'";