Having a problem of adding several "Field filters"

I have an issue, when I'm adding several "field filters" into my sql query as it's shown below, then when i start to apply those filters on my dashboard it depends from which filter I start. In this example below, it is import always to start from filter "partner" and then apply other filters, I can't start from filters "category" and etc., cause it'll show me error. If I write in each filter "where", in this case I can start from any filter I want but I can't apply them at the same time. Do you have any solutions in this case?

SELECT   id, 
partner, 
phone,
 category, 
 item_name, 
number_of_item

FROM  item_data

[[where {{partner}}]]
[[and {{category}}]]
[[and {{item_name}}]]
[[and {{phone}}]]

if you only fill category the query will end up like
SELECT id,
partner,
phone,
category,
item_name,
number_of_item

FROM item_data
and {{category}}

which is an invalid query

I would do like
SELECT id,
partner,
phone,
category,
item_name,
number_of_item

FROM item_data
where 1=1
[[and {{partner}}]]
[[and {{category}}]]
[[and {{item_name}}]]
[[and {{phone}}]]

1 Like

Great idea! Thank you !