title: Subquery returns more than one row - Mysql
body: <p>I'm trying to fetch the No.of Count in each city with Ascending order. But I get the error as subquery returns more than one row.</p>
  
  <p>Eg: One Table contains all the city,state and pincode. In another table we would have list of user records with their corresponding city. So I've tried to take the No.of users in each city with its count. </p>
  
  <p>EG: Table A </p>
  
  <pre><code>City State Pincode
  ABC  TN    600001
  ABD  TN    600001
  ABE  KA    500001
  ABF  KA    500002
  ABG  KA    500003
  CDE  KL    500004
  CDF  KL    500004
  </code></pre>
  
  <p>Table B</p>
  
  <pre><code>Userid Answer
  1      ABC
  2      ABC
  3      ABD
  4      ABD
  5      ABD
  6      ABD
  7      ABE
  8      ABE
  9      ABD
  10     ABC
  </code></pre>
  
  <p>Sql Query:</p>
  
  <pre><code>SELECT count(a.answer) from table b as a where a.answer=(select distinct(b.city) from table a as b);
  </code></pre>
  
  <p>So I'm getting subquery returns more than one row. Anybody help me to resolve this and would be much helpful to learn SQL Query.</p>