title: Can't work out MySQL Query
body: <p>I have a MySQL table which has the following data.</p>
  
  <pre><code>surveyid | staff  | username | ipaddress | rating  | comments 
  ---------|--------|----------|-----------|---------|----------
  0        | staff1 | user1    | 1.1.1.1   | 10      | none
  1        | staff2 | user2    | 1.2.1.1   | 5       | none
  2        | staff2 | user3    | 1.2.1.1   | 10      | none
  3        | staff2 | user2    | 1.2.1.1   | 6       | none
  4        | staff3 | user4    | 1.1.1.51  | 10      | none
  5        | staff4 | user3    | 1.21.12.1 | 9       | none
  6        | staff5 | user2    | 1.12.1.1  | 10      | none
  </code></pre>
  
  <p>I am wanting a query that will select surveyid, staff, username and ipaddress only when an ipaddress has been used for multiple users for the same staff.</p>
  
  <p>Basicly I am wanting to find out what staff has multiple users submit off the same ip address.</p>
  
  <p>I have tried the following but it does not work.</p>
  
  <pre><code>SELECT * FROM `comment_data` CD 
  INNER JOIN
  (SELECT `ipaddress`, COUNT(DISTINCT `staff`)
  FROM `comment_data` GROUP BY `ipaddress` HAVING COUNT(DISTINCT `staff`) &gt; 1 )
  USECOUNT ON USECOUNT.`ipaddress` = CD.`ipaddress`
  </code></pre>
  
  <p>I also tried the following query.</p>
  
  <pre><code>SELECT * FROM `commend_data` WHERE `staff`+`ipaddress` IN
  (SELECT `staff`+`ipaddress` FROM `comment_data` GROUP BY `staff`, `ipaddress`
  HAVING COUNT(`surveyid`) &gt; 1) 
  </code></pre>
  
  <p>Also I want to make sure I display all duplicates and I don't want to display just counts. </p>
  
  <p>If you need any more information please ask.</p>
  
  <p>Thanks
  Paul</p>