title: SQL Group By and Having error
body: <p>I have two tables. one is:</p>
  
  <pre><code>+--------------------------+-------------+------+-----+---------+
  | Field                    | Type        | Null | Key | Default |  
  +--------------------------+-------------+---------+-----+------+ 
  | facility_id              | int(10)     | NO   | PRI | NULL    |  
  | facility_name            | varchar(30) |      |     | NULL    |                 
  | facility_model           | varchar(25) |      |     | NULL    |                 
  +--------------------------+-------------+------+-----+---------+ 
  </code></pre>
  
  <p>another is:</p>
  
  <pre><code>+--------------------------+-------------+------+-----+---------+
  | Field                    | Type        | Null | Key | Default | 
  +--------------------------+-------------+---------+-----+------+ 
  | facility_id              | int(10)     | NO   | PRI | NULL    | 
  | facility_serial_number   | varchar(30) |      |     | NULL    |                 
  +--------------------------+-------------+------+-----+---------+
  </code></pre>
  
  <p>Different facilities could have same facility_serial_number (which is what we want to find out and fix). I want to get all the info of facilities that its facility_serial_number appears more than once.</p>
  
  <p>I tried to use group by and having:</p>
  
  <pre><code>select f1.facility_id, f1.facility_name, f1.facility_model, f2.facility_serial_number
  from f1, f2 on f1.facility_id = f2.facility_id
  group by f2.facility_serial_number
  having count (facility_serial_number) &gt; 2
  </code></pre>
  
  <p>It is wrong. I also tried other ways, but no success. What is the corerct query syntax? </p>