Re: Selecting Rows Based on Row Values Being in Array
| From: | kvigor | Date: | Thu, 05 Jul 2007 14:02:19 +0000 |
| Subject: | Re: Selecting Rows Based on Row Values Being in Array | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258320@lists.php.net to get a copy of this message | ||
Sorry,
That was a typo there's on one IN clause.
here is how it reads: SELECT * FROM central WHERE
CONCAT(strName,strCity,strState) IN('7orange50lbs','8purple60lbs').
So in my table I have 8 in size column, purple in color column, and 60lbs in
weight column.
Since the concatenated value will be 8purple60lbs, shouldn't MySQL return
that row? Thanks for your patience.
"Jim Lucas" <lists@cmsws.com> wrote in message
news:468C9C97.7080100@cmsws.com...
> kvigor wrote:
>>>> where is the part that it join()'s things together?
>> it's: $in_list =
>> "'".join("','",$list)."'";
> Good
>
>>
>>>> what is the output of the join() call
>> it's: '7orange50lbs','8purple60lbs' //once echo'd
> Fine
>
>>
>>
>> $query_One = "SELECT * FROM shoe WHERE CONCAT(size,color,weight)
>> IN({$in_list})";
>>
>> This is the results of $query_One:
>>
>> PHP echo returns:
>> SELECT * FROM shoe WHERE CONCAT(size,color,weight)
>> IN('7orange50lbs','8purple60lbs)
>>
>>
>> MySQL returns:
>> MySQL returned an empty result set (i.e. zero rows). (Query took 0.0008
>> sec)
>> SQL query:
>> SELECT *
>> FROM shoe
>> WHERE CONCAT( size, color, weight )
>> IN (SELECT * FROM shoe WHERE CONCAT(size,color,weight)
>> IN('7orange50lbs','8purple60lbs')
>
> ???
>
> What is wrong with the above statement?
>
> This should be an easy one for you to figure out?
>
>
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
>
> Give up?
>
> Well, looks like you are inserting the sql statement inside it self
>
> It should look like this
>
> SELECT *
> FROM shoe
> WHERE CONCAT( size, color, weight ) IN('7orange50lbs','8purple60lbs')
>
>
> not
>
> SELECT *
> FROM shoe
> WHERE CONCAT( size, color, weight )
> IN (SELECT * FROM shoe WHERE CONCAT(size,color,weight)
> IN('7orange50lbs','8purple60lbs')
>
> Notice the sub-select???
>
> Find where you are inserting the SQL into itself and remove it, and you
> might have the answer to your problems.
>
> Jim