Hi Dan, all!
Dan Rossi wrote:
> Hi, im having some issues with a sub query in mysql5 , i have a field
> which is storing a static comma seperate list of primary keys ie 1,2,3,4
Call me pedantic, but I get suspicious:
Is that a list of the four values "1", "2", "3", "4", or is it rather a
single character string "1,2,3,4" ?
Your text "static comma seperate list" makes me believe the latter.
> , i am then trying to use that to find entries in another table of the
> same primary keys here is the sql
>
> SELECT count(*) FROM feeds WHERE feedID IN (SELECT feeds FROM
> month_totals WHERE customerID=9 AND month_unique=1105)
>
> expected result should be 4 , i get 1. If i manually put in
>
> SELECT count(*) FROM feeds WHERE feedID IN (1,2,3,4)
>
> for instance i get 4
Here, SQL syntax clearly specifies that this is a list of 4 integer values.
>
> querying
>
> SELECT feeds FROM month_totals WHERE customerID=9 AND month_unique=1105
>
> gives me 1,2,3,4 , what seems to be the problem ?
Same question as above - a list of 4 values, or a single one?
Show us your "create table" for the involved tables, and also sample
data of "SELECT feedID FROM feeds".
Regards,
Jörg
--
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com