View Single Post
Old 09-26-2007, 11:44 AM   #2 (permalink)
Karl
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Hi there, try the following code

PHP Code:
 $count mysql_query("    SELECT 
                COUNT(DISTINCT commensimage.poster) as commensimage_count,  
                COUNT(DISTINCT commentsprofile.poster) as commentsprofile_count, 
                COUNT(DISTINCT commentscafe.poster) as commentscafe_count 
            FROM 
                commensimage, commentsprofile, commentscafe 
            WHERE 
                poster = 
$poster;") or die(mysql_error()); 
THis should return 3 seperate counts. If you wanted to add them all together and return the total, you can do something like this:

PHP Code:
SELECT 
                COUNT
(DISTINCT commensimage.poster) + 
                
COUNT(DISTINCT commentsprofile.poster) +
                
COUNT(DISTINCT commentscafe.poster) as total_count 
            FROM 
Karl is offline  
Reply With Quote