[eluser]new_igniter[/eluser]
Hello,
I am having tons of difficulty with this query. I am not too familiar with mySQL queries, so I don't understand what to change. Any help would be more appreciated.
* I have 3 tables, twibsDB, twibsReviews, twibsFeaturedVoting, each related by twibsID
o twibsDB - main table, bios, pic, username, etc
o twibsReviews - reviews relating to entities in twibsDB
o twibsFeaturedVoting - votes relating to entities in twibsDB
* I get 50 rows correctly back when I run the query, but the value for numRev is never right. It seems to be always the sum of ALL votes and not just the count relative to twibsID.
* I am trying to get the total number of votes for each entity for numRev. So if cnnbrk got 3 votes, numRev woudl be 3.
Code:
SELECT twibsID, twibAlias, twibName, twibBio, twibPic, twibLocation, twibURL, twibEmail, twibBlog, twibStore, twibPromotion, followersCount, created_at, count( tRating ) AS numRev, sum( vote ) AS vote
FROM twibsDB
JOIN twibsFeaturedVoting
USING ( twibsID )
LEFT JOIN twibsReviews
USING ( twibsID )
WHERE ( twibsFeaturedVoting.twibsID !=0 AND domainSource = '0')
AND (
twibsFeaturedVoting.createTime >= '2009-04-22'
AND twibsFeaturedVoting.createTime <= '2009-05-08'
)
GROUP BY `twibsID`
ORDER BY `vote` DESC
LIMIT 50