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() ORDER BY FIELD function

Featured Replies

Hi Gang,

I am reaching out to see if anyone can assist (or maybe point me in the right direction) with some ExecuteSQL() issues I am having in my my next version of my product.
 
I want to execute a query like the following:
 
SELECT code FROM Appts WHERE appt_id IN (’14’,’10’,’8’,’9') ORDER BY FIELD(appt_id, ‘9', ‘10', ‘8', ‘14’)
 
I have tried several times for this to return a working result with NO LUCK. Do you know if FMP allows this sort of query or does it fall short.
 
Appreciate any help. Thanks!

ORDER BY FIELD is not a valid expression in Filemaker SQL syntax. I can't figure out what exactly are you trying to achieve here, so I don't know what to suggest as an alternative.

 

 

Edited by comment

Ah. I was reading something else that made me realize what this is about. 

There is no FIELD function in Filemaker SQL syntax. To sort the records by custom sort order, try:

SELECT code 
FROM Appts 
WHERE appt_id IN (’14’,’10’,’8’,’9') 
ORDER BY CASE appt_id 
   WHEN '9' THEN '1'
   WHEN '10' THEN '2'
   WHEN '8' THEN '3'
   ELSE '4' END 

 

  • Author

Thanks COMMENT! With a little fudging I got it working with your suggestion. Happy New Year!!!

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.