P J Posted June 19, 2014 Posted June 19, 2014 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....
jlamprecht Posted June 19, 2014 Posted June 19, 2014 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.
P J Posted June 20, 2014 Author Posted June 20, 2014 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...
Recommended Posts
This topic is 3919 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 accountSign in
Already have an account? Sign in here.
Sign In Now