AnsweredAssumed Answered

executeSQL using a comma separated list of ID's

Question asked by LuukvanSummeren on May 29, 2015
Latest reply on May 29, 2015 by philmodjunk

Title

executeSQL using a comma separated list of ID's

Post

LS

Im having a bit of a struggle with the executeSQL funtion of FM12 pro.

In my database there is a table of students with a unique studentID, a table of courses with a unique courseID and a field to state if the course is active or not, and a table to add students to a course.

Im trying to write a script to print a list of students enroled in active courses.

I can execute a SQL query to get a variable containg all active courses, say $courses = 13,14,15,16,21

Now I would like to use this commaseperated "list" in a second query to generate a list of student ID's and names from my student table using someting like WHERE courseID IN (13,14,15,16,21). Ive tried to parse this variable into a second query but this doenst seem to work, am I overlooking something? my query:

ExecuteSQL ("
SELECT StudentID
FROM subscriptions
WHERE courseID IN (?)";
 "" ; "" ;$courses )

Thanx in advance

Outcomes