Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4450 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

How does one write a SELECT statement to find records with id that match any one id listed in a multi-key field?

 

The following does not work because the contents of the multikeyfield will not entirely equal any individual record id.

 

ExecuteSQL ( "SELECT field FROM table WHERE id=?" ; "" ; "¶" ; multikeyfield )

Posted

The multi-key is return delimited. If they are all NUMBERS in the id field, you might try to change the returns to comma and use the IN comparison:

ExecuteSQL ( " SELECT field FROM table WHERE id IN (?) " ; "" ; "¶" ; Substitute(multikeyfield;"¶";',' )

That should make it IN (1,2,3,4,5)

Try it and see.

Posted

That makes perfect sense to me, but I can't get it to work.

 

I even tried hardcoding it like this in the data viewer:

 

This works (but there's only one value):

 

ExecuteSQL ( " SELECT ancestorsList FROM products_CATEGORIES WHERE id IN (?) " ; "" ; "¶" ; "10036" )

 

But with any of the following, nothing is returned.

 

ExecuteSQL ( " SELECT ancestorsList FROM products_CATEGORIES WHERE id IN (?) " ; "" ; "¶" ; "10036,10039" )

 

with a space after comma:

ExecuteSQL ( " SELECT ancestorsList FROM products_CATEGORIES WHERE id IN (?) " ; "" ; "¶" ; "10036,10039" )

 

with single quotes around each value:

ExecuteSQL ( " SELECT ancestorsList FROM products_CATEGORIES WHERE id IN (?) " ; "" ; "¶" ; "'10036','10039'" )

This topic is 4450 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.