List:General Discussion« Previous MessageNext Message »
From:kalin m Date:April 7 2010 3:37pm
Subject:subquery multiple rows
View as plain text  
hi all...

i have a bit of a problem with this:

table products:

----------------------
prod  |  category |
---------------------|
boots |  winter    |
boots | summer  |
boots | spring     |
shoes | spring     |
shoes | winter    |
shoes | fall         |
shoes | summer  |
----------------------

when i do this:
 > select distinct prod as m, (select category from products where email 
= m) as n from products;

i get:

ERROR 1242 (21000): Subquery returns more than 1 row

i know that the subquery returns more than one rows. i hope so...

what i'd like to see as result is:

-------------------------------------------------
m         | n                                             |
-------------------------------------------------
boots   |  winter, summer, spring          |
shoes   |  spring, winter, fall , summer  |
-------------------------------------------------


or at least:

---------------
m         | n  |
---------------
boots   |  3  |
shoes   |  4  |
----------------




thanks....




Thread
subquery multiple rowskalin m7 Apr
  • Re: subquery multiple rowsnwood7 Apr
  • Re: subquery multiple rowsNathan Sullivan7 Apr
    • Re: subquery multiple rowskalin m7 Apr
      • RE: subquery multiple rowsSteven Staples12 Apr