Passing a List to a ServerConnect using "IN"

Hello Wapplers,

I’m filtering a query based on a form, which passes the value of a dropdown to a SC through GET. Regular stuff.
The query works when a single letter is passed, i.e. C or U, but returns empty when the default value of C,U is passed.

Here is the searchrole form element.
image

And the query uses “IN” as I want both letters to be found and the whole list of people returned. (leaving it empty and passing nothing/Null doesn’t work either
image

Any idea how to make this work?

IN expects an array to be passed as a value, not a comma separated list.

Sorry if I need more info here.

Is an array required? I see lots of MySQL tutorials (ex: https://www.mysqltutorial.org/mysql-basics/mysql-in/) where the syntax is SELECT 1 IN (1,2,3); and there is no mention of arrays. (Pls note I fully realise you are not here to teach SQL, it’s just what I see while researching).
In addition, IN works well on a single value (ex: for the values C or U) which are not set as arrays.

In case an array is required, how do I place an array syntax in the form dropdown values?

Thanks again :slight_smile:

The rules for the sql language and for the Wappler action are different. The action adds functionality to make queries easier. The Wappler query action expects an array when using the IN clause. You can use the split formatter on your comma separated string to create an array.

1 Like

Ken’s reply is correct, adding to it:

Add the split formatter to your get variable:

Split the string on ,:

Result:

1 Like

I don’t suppose anyone has got this to work first time, without seeking help. A hint of some sort in the UI would be helpful and prevent frustration.

1 Like

@mebeingken @Teodor @TomD
Understood, made the change works perfectly.
This allows for the form comma-separated values passed to the SC to be split for Wappler internal use, then Wappler passes it along to the mySQL DB as CSVs.
All good, works 100% well.
Thanks!