#Query using two multiselect widgets

1 messages · Page 1 of 1 (latest)

blissful crest
#

I'm looking for A MYSQL query that selects records from TableA where the status column = items selected in multiselect1 and the techs column contains items selected in multiselect2 as part of the string stored in the techs field.

rigid abyssBOT
#

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

blissful crest
#

That example worked for me.

rigid abyssBOT
#

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