title: Mysql sub query with multiple rows returned
body: <p>I am trying to get the zip codes that are within a certain latitude and longitude and then using the zip codes returned pull all posts within the given area. The numbers for latitude and longitude are variables but for testing purposes they are hard numbers.
  Can someone guide me in the right direction to make this work?</p>
  
  <p>Query #1 - works selects post</p>
  
  <pre><code>SELECT user_id, session, zip, price, city, state, post_id, category, shortDesc,  fpi 
  FROM post ORDER BY post.post_id DESC;
  </code></pre>
  
  <p>Query #2 - works selects zip codes in area</p>
  
  <pre><code>SELECT count(value) as duplicate, value 
  from (SELECT DISTINCT zipcode as value from zip 
    WHERE latitude BETWEEN 27.747 AND 28.147 
    UNION all 
     SELECT DISTINCT zipcode FROM zip 
     WHERE longitude BETWEEN -82.657 AND -82.257) 
  as tbl group by value having count(value) &gt; 1;
  </code></pre>
  
  <p>Query as subquery</p>
  
  <p>Tried: Failed</p>
  
  <pre><code>SELECT user_id, session, zip, price, city, state, post_id, category, shortDesc,  fpi 
  FROM post 
  WHERE zip = (
    SELECT count(value) as duplicate ,value 
    from (SELECT DISTINCT zipcode as value from zip 
      WHERE latitude BETWEEN 27.747 AND 28.147 
      UNION all SELECT DISTINCT zipcode FROM zip 
       WHERE longitude BETWEEN -82.657 AND -82.257) 
    as tbl group by value having count(value) &gt; 1) 
  ORDER BY post.post_id DESC;
  </code></pre>
  
  <p>error #1241 - Operand should contain 1 column(s)</p>
  
  <p>Next Try: FAILED</p>
  
  <pre><code>SELECT user_id, session, zip, price, city, state, post_id, category, shortDesc,  fpi 
  FROM post WHERE zip = (select distinct zipcode from zip 
    where latitude between 27.747 AND 28.147) 
    IN ( select distinct zipcode from zip 
      where longitude between -82.657 AND -82.257);
  </code></pre>
  
  <p>1242 - Sub query returns more than 1 row</p>
  
  <p>Next Try: FAILED </p>
  
  <pre><code>SELECT user_id, session, zip, price, city, state, post_id, category, shortDesc,  fpi 
  FROM post 
  WHERE zip = ANY (
    select distinct zipcode from zip 
    where latitude between 27.747 AND 28.147) 
  IN ( select distinct zipcode from zip 
       where longitude between -82.657 AND -82.257);
  </code></pre>
  
  <p>1064 - You have an error in your SQL syntax;</p>