Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ExecuteSQL with Multi-key

Featured Replies

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 )

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.

  • Author

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'" )

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.