title: Getting duplicated sql result
body: <p>I have 3 tables: Users, Articles and Votes </p>
  
  <pre><code>| Users |    | Articles |    |   Votes   |
  |   id  |    |    id    |    |  userId   |
  |  name |    |  title   |    | articleId |
  | email |    |  userId  |    |    type   |
  </code></pre>
  
  <p>I want to get users list with Count voteup and Count votedown for each one.</p>
  
  <p>I'm testing this query:</p>
  
  <pre><code>SELECT u.id,u.name,u.email,
  (SELECT COUNT(*) FROM votes as v WHERE v.type=1 AND v.articleId IN 
     (SELECT a.id From articles as a WHERE a.userId = u.id) ) AS totalvoteup,
  (SELECT COUNT(*) FROM votes as v WHERE v.type=0 AND v.articleId IN 
     (SELECT a.id From articles as a WHERE a.userId = u.id) ) AS totalvotedown
  FROM users as u
  </code></pre>
  
  <p>I have the list I want when I test it via phpmyadmin(the results number matches with the number of users in the table), but when I try to get through Node server(from AngularJs or Postman) I'm getting duplicate results:</p>
  
  <pre><code>{
  "users": [
  [
    {
      "id": 1,
      "name": "John Lennon",
      "email": "johnlennon@gmail.com",
      "totalvoteup": 0,
      "totalvotedown": 0
    },
    {
      "id": 2,
      "name": "John Lennon 2",
      "email": "johnlennon2@gmail.com",
      "totalvoteup": 0,
      "totalvotedown": 0
    },
    {
      "id": 3,
      "name": "John Lennon 3",
      "email": "johnlennon3@gmail.com",
      "totalvoteup": 0,
      "totalvotedown": 1
    },
    {
      "id": 4,
      "name": "John Lennon 4",
      "email": "johnlennon4@gmail.com",
      "totalvoteup": 0,
      "totalvotedown": 0
    }
  ],
  [
    {
      "id": 1,
      "name": "John Lennon 1",
      "email": "johnlennon1@gmail.com",
      "totalvoteup": 0,
      "totalvotedown": 0
    },
    {
      "id": 2,
      "name": "John Lennon 2",
      "email": "johnlennon2@gmail.com",
      "totalvoteup": 0,
      "totalvotedown": 0
    },
    {
      "id": 3,
      "name": "John Lennon 3",
      "email": "johnlennon3@gmail.com",
      "totalvoteup": 0,
      "totalvotedown": 1
    },
    {
      "id": 4,
      "name": "John Lennon 4",
      "email": "johnlennon4@gmail.com",
      "totalvoteup": 0,
      "totalvotedown": 0
    }
  ]
  ]
  }
  </code></pre>
  
  <p>Any ideas how to resolve this?</p>