The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#11
|
||||
|
||||
Quote:
PHP Code:
|
#12
|
||||
|
||||
You need to put parentheses around the asterix sabe :
[sql] SELECT COUNT(*) as total FROM user [/sql] |
#13
|
||||
|
||||
Btw, the reason you were returning more than one result is because of the session timeout. You shouldn't need to group by at all if you add this clause to your query:
AND session.lastactivity > " . (TIMENOW - $vboptions['cookietimeout']) . " |
#14
|
|||
|
|||
Quote:
PHP Code:
i run about 100 tests lol and i surely can say that i understand left joins better now i want to run count inside the left join and i need to update counters for each team :\ sucks Quote:
i want to do like user.posts =5 (userid=1) user.posts=6 (userid=5) total teams posts = 6 can i do query for that? never mind i fixed it this is the query [SQL] $teamslist = $DB_site->query(" SELECT teams.*,user.username AS username, user.userid AS userid ,user.posts AS userposts, user.reputation AS userrep,COUNT(user.posts) AS totalteamposts FROM " . TABLE_PREFIX . "teams AS teams LEFT JOIN user ON(teams.teamid = user.teamid) WHERE teams.teamid > 1 GROUP BY teams.teamid "); [/SQL] |
#15
|
||||
|
||||
Quote:
|
#16
|
|||
|
|||
heh my mistake - to tierd you right shuold be 11
how am i doing that ? do i need an exstra query for update ? cuse now i will need to run 1 exstra query for each team... |
#17
|
||||
|
||||
Quote:
or if you've already got the posts, just do a mysql_num_rows() on the query, either will give you the info you desire. |
#18
|
|||
|
|||
you got me worng
i did this query PHP Code:
so i want to update teams.teamposts now the value of total team posts is in $teams['totalteamposts'] now my qustion is if there a way to update teams.teamposts=$teams['totalteamposts'] without exstra query or if i must use exstra query do i need to run the query for each team (in the while loop) so code should look like that PHP Code:
if i got 100 teams i add 100 query's something i dont want to do so im looking for other way... any ideas ? |
#19
|
||||
|
||||
you're best bet would be to psuedo cache the data
in the while have $count++ $row[$count] = $totalteamposts then outside of the while add up the data from $row[0] -> $row[10] and beneath that to the update saying that, not being sure if you can do that, it might now work. actually ignore that, i know it's simpler than that, i'll have to come back to this, my minds gone blank ahhh that's it try $totalteamposts .= $teamposts[posts] . " + "; then just remove the extra " + " at the end and throw it into a ceil() |
#20
|
|||
|
|||
Quote:
well dosent help me much my problem isnt about counting cuse im doing it on the first query my problem is to update do i need to run exstra query for every team ? there must be an other way... to update all teams in 1 query. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|