Re: Selecting Rows Based on Row Values Being in Array
| From: | Jim Lucas | Date: | Thu, 05 Jul 2007 07:24:07 +0000 |
| Subject: | Re: Selecting Rows Based on Row Values Being in Array | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258299@lists.php.net to get a copy of this message | ||
kvigor wrote:
it's: $in_list = "'".join("','",$list)."'"; Goodwhere is the part that it join()'s things together?
it's: '7orange50lbs','8purple60lbs' //once echo'd Finewhat is the output of the join() call
$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