Re: Selecting Rows Based on Row Values Being in Array

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

 



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

--
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