mysql查询,给我错误的行数

I am trying to create a search page and this is my query. I have 3 tables, 'services', 'ratings' and 'shops'. 'Shops' contains 88 results, whilst 'ratings' contains 93, when using: $nr = mysql_num_rows($result); It returns the 93, not 88 like I expected, how do i return the 88 shops, it actually doubles up results for shops that have more than 1 rating. eg: if the shop has 2 votes, the shop appears twice.

    $result = mysql_query("SELECT services.*, ratings.*, shops.*, temp.total as final_total, 
CONCAT(shop_number, ' ', shop_location, ' ', shop_city, ' ', shop_province, ' ', shop_postcode) AS address FROM shops

inner join services on shops.shop_id=services.shop_id   
inner join ratings on shops.shop_id=ratings.shop_id
inner join (select SUM(comfort + service + ambience + friendliness)/(12) / COUNT(shop_id) AS total, shop_id FROM ratings GROUP BY shop_id ) as temp on shops.shop_id=temp.shop_id 
    HAVING temp.total >= '$search_total_rating'

    AND address LIKE '%$search_shop_address%' 
    AND shop_name LIKE '%$search_shop_name%'
    AND comfort >= '$search_shop_comfort' 
    AND service >= '$search_shop_service' 
    AND ambience >= '$search_shop_ambience' 
    AND friendliness >= '$search_shop_friendliness'
         ORDER BY shop_name ASC");