Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using the IN clause
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00576615
Message ID:
00576652
Views:
19
Thanks Vlas this looks really helpful.

Jeremy
>Hi!
>
>The most simple way:
>select * from Contact where ","+allt(str(contact.ID))+"," $ ","+?ListOfIDs+","
>Note that list should be comma-separated list of ID values without the spaces in it.
>
>If this is for VFP only without prediction to move to another backend, you can use "&":
>select * from Contact where contact.ID in (&ListOfIDs)
>But this accepts limited number of ID values in the string.
>
>One more approach: use alines(MyArray,chrtran(ListOfIDs,",",chr(13))), then use that array. You can also copy array into the temporary cursor, index that cursor, and then join that cursor withlist of ID values to the main query:
>
>alines(MyArray,chrtran(ListOfIDs,",",chr(13)))
>... copy array to cursor MyCursor
>select * from Contact inner join MyCursor on Contact.ID=MyCursor.ID
>
>The last way is very effective for very large data and long list of ID values. Though to convert it, for example, to SQL Server need to write special scripts.
>
>HTH.
>
>>Can anybody lend a hand with this one.
>>
>>I'm storing a comma delimited list of ID's in a field and I wanted to do a
>>
>>select * from Contact where contact.ID in ?ListOfIDs
>>
>>But because the ID is an integer and the list is a string it gives me an error "operator/operand type mismatch"
>>
>>Any sujestions as to how I overcome this?
Caroline
Previous
Reply
Map
View

Click here to load this message in the networking platform