userlist= {"01E1B5C0651EDA80", "F62B70921920FCBE", "909D35028E2039CE"};
sqlstr_ =
"SELECT \!"t1\!".uid
FROM \!"Tables\!".\!"Table\!" \!"t1\!"
WHERE ( \!"t1\!".uid IN ( '^
concatitems(userlist,\!"','\!")
^') )
;";
write(Eval Insert( sqlstr_ ));
The leading and trailing apostrophes are handled differently from the interior apostrophes; see just before and after the ^, vs the separator string. If there is any possibility userlist could have 0 items, you should check for that before running the query because it will probably not make any sense.
You can make it a little more readable using the other escape mechanism (html does not know about it so the syntax coloring is wrong on the web):
userlist= {"01E1B5C0651EDA80", "F62B70921920FCBE", "909D35028E2039CE"};
sqlstr_ =
"\[
SELECT "t1".uid
FROM "Tables"."Table" "t1"
WHERE ( "t1".uid IN ( '^
concatitems(userlist,"','")
^') );
]\";
write(Eval Insert( sqlstr_ ));
Using write() to display the result helps too:
SELECT "t1".uid
FROM "Tables"."Table" "t1"
WHERE ( "t1".uid IN ( '01E1B5C0651EDA80','F62B70921920FCBE','909D35028E2039CE') );
Craige