This topic is locked
[SOLVED]

 Perform Query Then Insert Output Into SQL "IN" Statement

5/19/2020 4:56:15 PM
PHPRunner General questions
C
copper21 author

Hello All,
This is driving me nuts. I have a simple query: "SELECT District From WorkLocations WHERE A = 1". I need to take the output of that query, which consists of about 12 work locations, and then use that data to input it into a SQL query using $strWhereClause on the List page of a project. How do I form the first query to get the output I need consisting of multiple work locations and then put it in the format for the "IN" clause so it looks like SELECT * FROM Table WHERE District IN ('D1','D2','D3','D4','D5').....D1-D5 represent the output from the first query.
Thanks again in advance.
Brian

K
keithh0427 5/19/2020

Have you tried
SELECT * FROM Table WHERE District IN (SELECT District From WorkLocations WHERE A = 1)

C
copper21 author 5/21/2020



Have you tried
SELECT * FROM Table WHERE District IN (SELECT District From WorkLocations WHERE A = 1)


That did it, thank you! I was overthinking it.