dadada dadada - 3 years ago 188
SQL Question

how to count in one table and get record from another table

I need help with the following query
i have 2 tables first one location with primary key no_location and one of the entry no_membre and second table membre with no_membre as primary key and entries prenom_membre and nom_membre
I need to know how to get prenom_membre and nom_membre of members that did more than 25 location.
thank you in advance

Answer Source

use HAVING clause to determine the result set to have more than 25 locations.

   SELECT prenom_membre,
           nom_membre,
           COUNT(no_location)
      FROM membre m
      JOIN location l
        ON m.no_membre = l.no_membre
     GROUP BY prenom_membre,
              nom_membre
    HAVING COUNT(no_location) > 25
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download