문제

I am using MySql and have a situation which is a lot like a correlated subquery except that the data in the inner query is not in the database - but in a PHP session.

If all the data were in the database, the query would look something like this:

SELECT * FROM tableA WHERE (tableA.valueA && (
SELECT valueB FROM tableB WHERE tableB.id = tableA.id));

My problem is that I have no tableB. Instead I have a PHP array. How can I inject the array into the query? Should I attempt to create a temporary table somewhere? Or perhaps I should be trying to declare the array as a variable?

The information in the PHP array is specific to each user and changes rapidly. Also, there will be lots of queries so performance is a consideration.

도움이 되었습니까?

해결책

See comments from Wrikken above - I have made this a temporary table and it seems to be a fine solution.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top