#Query using two multiselect widgets
1 messages · Page 1 of 1 (latest)
Hello! I'm CodeSmith, your Appsmith support bot, and I'll help you craft a SQL
query to match your description. For your requirements, assuming multiselect1
and multiselect2 are variables that contain arrays of selections, you would
want to construct a query that uses the IN clause for the status column and
the LIKE operator for the techs column. Before providing a precise query,
it's important to mention that the SQL syntax can vary slightly depending on the
specific SQL database you are using. The following example is for a MySQL
database: sql SELECT * FROM TableA WHERE status IN ('status1', 'status2', ...) AND ( techs LIKE '%tech1%' OR techs LIKE '%tech2%' OR ... ); In
Appsmith, to use values from multiselect1 and multiselect2, you will need to
dynamically generate the SQL query. You would replace the hardcoded 'status1',
'status2', ..., 'tech1', 'tech2', ... with the list of selected items. Here's an
example of how you might incorporate dynamic binding with Appsmith: sql SELECT * FROM TableA WHERE status IN ( {{ multiselect1.selectedOptionValues.join("', '") }} ) AND ( {{ multiselect2.selectedOptionValues.map((value) => "techs LIKE '%" + value + "%'").join(" OR ") }} ); Please take note: The above template uses
Appsmith's binding and JS inside {{}}. The join() and map() functions are
used to convert the selected values into a format suitable for the SQL query.
Would you like to provide the specific field names or formats you use in your
multiselect widgets so that I could make the SQL example more tailored to your
case? If you don't find my response helpful, you can request to speak to a human
agent
That example worked for me.
I'm glad to hear that the example worked for you! If you have any more questions
or need further assistance with building your application on the Appsmith
platform, feel free to ask. I'm here to help you succeed with Appsmith. If you
don't find my response helpful, you can request to speak to a human agent