1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Issues with a mysql query , sub query?

Discussion in 'MySQL' started by Jawn, May 31, 2010.

  1. #1
    Hello

    Im not sure how to solve this but i want my query to only count totalaverage if number of webhosting ratings are more than "3"

    But im not sure how to do this and would really appreciate if someone could help me.

    
    SELECT 
    SQL_CALC_FOUND_ROWS 
    COUNT(c.reliability), 
    a.packetname, 
    a.drivespace, 
    a.traffic, 
    a.yearlyprice, 
    b.title, 
    b.logoimage, 
    b.urlsafe, 
    (AVG(c.reliability) + AVG(c.support) + AVG(c.cost)) / 3 AS totalaverage 
    FROM 
    webhosting_companies_packets AS a 
    LEFT JOIN 
    webhosting_companies AS b ON a.wid = b.id 
    LEFT JOIN 
    webhosting_companies_rating AS c ON c.wid = a.wid 
    WHERE 1 
    GROUP BY 
    a.id 
    ORDER BY 
    totalaverage DESC
    
    
    Code (markup):
    I guess you cant have another condition on left join? like

    
    LEFT JOIN 
    webhosting_companies_rating AS c ON c.wid = a.wid AND COUNT(c.reliability) > 3
    
    Code (markup):

    Best Regards

    John
     
    Jawn, May 31, 2010 IP
  2. chtdatweb

    chtdatweb Well-Known Member

    Messages:
    1,473
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    160
    #2
    How about this?

    WHERE 1 GROUP BY a.id AND totalaverage > 3 ORDER BY totalaverage DESC
    Code (markup):
     
    chtdatweb, Jun 2, 2010 IP