Using if then else in query

I have a query

SELECT * FROM table WHERE account_id = {{ urlparams.accountId }} and id = {{ listbox1.selectedLabel }}

how can i add a
IF listbox2.selectedLabel is not empty, replace the "and id = {{ listbox1.selectedLabel }}" by "and issue = {{ listbox2.selectedLabel }}"
else if listbox3.selectedLabel is not empty, by "and category = {{ listbox3.selectedLabel }}" ?

Thanks

Use a CASE statement...

1 Like