Re: MYSQL query help
| From: | Miles Thompson | Date: | Fri, 14 Dec 2001 14:57:51 +0000 |
| Subject: | Re: MYSQL query help | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15032@lists.php.net to get a copy of this message | ||
It's not the IN, it's the sub-query you cannot use. MySQL doesn't support them and it's just about the main reason I don't like it.
Alternatives? You could execute your subquery and return the results to an array. Loop through the array, using the index and the indexed element to drive a series of queries, accumulating your results as you go.
If the number of items return by the subquery is not large, you could build an "in set", for lack of a better term, so you would end up with " ... and IN ("first", "second", ..."nth") ". (Check syntax!!) But that's likely to be slower than cold molasses and run like a pig.
If you're not too far into the project, and you will have a lot of subqueries, switch to PostgreSQL or a database that supports them.
I don't really have an answer. I hope someone comes up with a more elegant solution.
Regards - Miles Thompson
At 09:34 AM 12/14/2001 -0500, Harpreet wrote:
I dont think we can use 'IN' and 'NOT IN' in mysql. Is there an alternative that would work? select * from lib_asset_tbl where material_id <>'' and asset_id in (select asset_id from lib_copy_tbl) Help is appreciated. Regards, Harpreet Kaur Software Developer Crispin Corporations Inc. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net