Hi there,
I am trying to pull info from a database using user input in number input boxes. I want the users to be able to enter any of the fields or any number of the fields and it be filtered by that, for example if a user wants to filter by account number and year and serial, then they can enter all 3 of those options and leave the other options empty. However I'm pretty new to sql and also new to ReTool so I'm struggling to find a way to do this that doesn't use a ton of ANDs in the WHERE clause.
Here is the basic look of the tool
I want to be able to put in any of the options on the left to help filter the table on the right but I'm stuck. I essentially want to recreate the filter at the bottom but using easy to fill out input for the users..
In other tabs of this page I've done queries for 3 inputs using basically the below where clause
WHERE
(dbo.Asmt_ExemptionDetail.AcctNmbr = {{ exempt_acctnum.value}}
AND dbo.Asmt_ExemptionDetail.AsmtYear = {{ exempt_asmtyr.value }}
AND dbo.Asmt_ExemptionDetail.ExemptCode LIKE {{ '%' + exempt_code.value + '%' }})
OR
(dbo.Asmt_ExemptionDetail.AcctNmbr = {{ exempt_acctnum.value}}
AND dbo.Asmt_ExemptionDetail.AsmtYear = {{ exempt_asmtyr.value }}
AND {{ exempt_code.value}} = '""')
OR
(dbo.Asmt_ExemptionDetail.AcctNmbr = {{ exempt_acctnum.value}}
AND {{ exempt_asmtyr.value }} IS NULL
AND dbo.Asmt_ExemptionDetail.ExemptCode LIKE {{ '%' + exempt_code.value + '%' }})
OR
({{ exempt_acctnum.value}} IS NULL
AND dbo.Asmt_ExemptionDetail.AsmtYear = {{ exempt_asmtyr.value }}
AND dbo.Asmt_ExemptionDetail.ExemptCode LIKE {{ '%' + exempt_code.value + '%' }})`Preformatted text`