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 - Field cannot be found

Featured Replies

  • Newbies

Hello, 

I am extremely new to working with SQL, so i am currently fumbling my way through achieving my required outcomes. 

To explain further explain my issue, i created a table/layout on one of my databases that i could use to practice and visualize the outcomes of ExecuteSQL. 

I type into my "query" field and that drives a separate ExecuteSQL calculation. 

I have been able to achieve the required outcome in this field, however when i transfer the query directly into a ExecuteSQL calculation i get errors. These relate to the field in financials called "Cost Code"

If i attempt the same calculation without it, i can run it without an issue. However what confuses me is it will work when input through a query field. 

Query field;

SELECT SUM(Total)
FROM financials
Where "Cost Code" = 'FA' and EID = '982 000147908607'

Please find attached images highlighting and showing everything relevant. 

 

Kind regards
Pat

 

SQL Error 1.PNG

SQL Error 2.PNG

Hi Pat,

Since the Cost Code field name contains a space you need to wrap it in double quotes as you have done, but... furthermore... you need to escape the double quotes by prepending a backslash character.

ExecuteSQL ( 

"SELECT SUM(Total)
FROM financials
Where \"Cost Code\" = 'FA' and EID = '982 000147908607' " 

; "" ; "" ) 

Also, I would take advantage of dynamic parameters and construct the query like so:

ExecuteSQL ( 

"SELECT SUM(Total)
FROM financials
Where \"Cost Code\" = ? and EID = ? " 

; "" ; "" ; "FA" ; "982 000147908607" ) 

Hope this helps,

Kevin

  • Author
  • Newbies

Thank you Kevin,  that allows me to accomplish exactly what i needed to without creating a ridiculous number of relationships. 
I feel silly to have never considered the space, live and learn. 

 

Kind regards
Pat

I'm really surprised that Total is NOT a SQL reserved word

Create an account or sign in to comment

Similar Content

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.