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 

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.
>Harpreet Kaur
>Software Developer
>Crispin Corporations Inc.
>PHP Database Mailing List (
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to