Re: Selecting Rows Based on Row Values Being in Array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>where is the part that it join()'s things together?
it's: $in_list = "'".join("','",$list)."'";

>>what is the output of the join() call
it's: '7orange50lbs','8purple60lbs' //once echo'd


$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')

Row 1 and Row 2 should return because:
columns 9-11 are equal to:
7     orange     50lbs
8     purple     60lbs        Hope all this helps
===============================
"Jim Lucas" <lists@xxxxxxxxx> wrote in message 
news:468B2E5D.2040202@xxxxxxxxxxxx
> kvigor wrote:
>> Jim,
>>
>> Thanks for all you help.  Tell me where to mail you the check 
>> "seriously". If we get this right I'll owe you.
>>
>> OK, the query string now looks like you said it would.  However Query 
>> isn't returning a match.
>> //DETAILS=========================================================
>>
>> My $list array looks like this one echo'd:
>>
>> $list[0] =7orange50lbs
>> $list[1] =8purple60lbs
>>
>>
> where is the part that it join()'s things together?
> what is the output of the join() call
>
>> Now when I do this:
>>
>> $query_One= "SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
>> IN({$in_list})";
>
> echo $query_One;
>
> and show me the results of the echo
>
> also, run this SQL statement in phpmyadmin and see what it returns
>
>>
>> $result = mysql_query($query_One,$connection) or die("Query failed: ". 
>> mysql_error($connection));
>
> get rid of this, basically you are throwing away your first row of 
> results.
>> $row = mysql_fetch_assoc($result);
>>
>>   while($row = mysql_fetch_assoc($result))
>>   {extract($row);
>>   echo "<table width='2400' cellpadding='5' cellspacing='5' 
>> class='tborder'><tr>
>>       <td width='46' border = '1' bordercolor ='#3E5C92' height='20' 
>> align='left' class='tcat'>$count</td>
>>       <td width='200' align='left' class='row2'>$size</td>
>>       <td width='200' align='left' class='row2'>$color</td>
>>       <td width='200' align='left' class='row2'>$weight</td>
>>       </tr>
>>       </table>";
>>   }
>> No rows are returned to the screen.  I know I should at least have 2 rows 
>> return because my TABLE has 2 rows in it and both rows are in $in_list[0] 
>> and[1].
>>
>>                           size  color       weight
>> Row1 looks like: 7     orange     50lbs    //This is from phpMyAdmin 
>> table export
>> Row2 looks like: 8     purple     60lbs    //This is from phpMyAdmin 
>> table export
>>
>>
>> I get no MySQL errors either.  So I'm wondering why aren't rows 
>> returning?
>> //END 
>> DETAILS==============================================================
>
> -- 
> Jim Lucas
>
>    "Some men are born to greatness, some achieve greatness,
>        and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
>     by William Shakespeare 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux