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.

Problem with IN sub clause

Featured Replies

I have a query along the lines of

 

ExecuteSQL ( "SELECT IDa, Name, Age FROM tableA WHERE  IDa IN ( SELECT IDb FROM tableB WHERE IDc = '1234' )" ; "XX"; "YY" )

 

I have removed most of the fields to be returned as well as additional WHERE criteria that is working.

 

I need the XX and YY in the outside query, but I need commas as the record separator for the IN ( SELECT... sub query

 

Am I missing something obvious....

I would take that IN clause out and run it as its own ExecuteSQL and put the result into a variable. Format it correctly in the fashion IN ('1','2','3'). Then put the variable into your ExecuteSQL you have provided.

  • Author

Sorry, I clearly didn't provide enough information.  

 

I realise that your suggestion is technically a good solution.  In my circumstances I have a single ExecuteSQL which is dynamically generated.  A variable contains either a basic WHERE structure and or the IN sub query.  To take your suggestion would require fundamental re structuring of what is a parameter driven generic process which I'd rather avoid.

 

I tried nesting ExecuteSQL, but was unable to get it to work.  I was hoping that there was something clever in SQL itself that would help me (not being an expert myself)

 

Actual query look more like this

 

ExecuteSQL ( "SELECT " & $fieldlist & " FROM " & $tablename & " WHERE  " & $whereQuery AND active = 1 " ;  "XX"; "YY" )

 

Where $whereQuery is either

 

"IN ( SELECT " & $inField & " FROM " & $inTable &" WHERE " & $qField & " = '" & $qData & "' )" 

 

Or more usually

 

"$qField & " = '" & $qData & "'" 

 

Thanks for your input.  In responding I have thought of a couple of ideas to try...

 

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.