Where clause in query json with sql

Hello, I'm currently developing an app that allows users to filter companies from a table. The user selects a company from a list, which is used to apply a filter in a 'where' condition. For example, if the user selects Company A the filter in the query would be 'company IN ("Company A").

However, a challenge arises when the user wants to see more than one company. In this case, the query would look like 'company IN (""Company A", "Company B"").' The issue is that the double quotation marks are repeated, causing the query to search for a non-existent company that combines both names.

Here's a real code fragment illustrating the problem:
WHERE Company IN ({{ company_list.value }})

  • Result of selecting one company: WHERE Company IN ({{"Company A"}})
  • Result of selecting multiple companies: WHERE Company IN ({{""Company A", "Company B""}})

To resolve this issue, the query should be: WHERE Company IN ({{"Company A", "Company B"}}) In this case, the double quotation marks are used only once for each company.

Could you please advise on how I can fix this?

Have you tried using WHERE company = ANY({{table.data}}) assuming table.data is already filtered.

Hi ScottR, thanks for your reply.

I tried using Company = ANY({{Company_list.data}}) but the result is blank, is not working.

Any other workaround?

Can you share some screen shots?

Hey Scott,

yes, this is the component with the companies that can be selected by the user:
CleanShot 2023-05-24 at 14.35.01

Here is the "Company = ANY ({{Company_list.data}})" result when selecting company A:
CleanShot 2023-05-24 at 14.37.44

If you need something specific let me know, thank you for looking into this.

You can't use tabs as far as I can tell...you should store that either in a list or in a table.... and then query it.

I tried with both a list and a table but the result keeps being blank. :broken_heart:
Here is a screenshot of the list and the code:

Any other approach on this?

company_list.data should probably be company_list.value