Filtering Database Query with Multiple Checkboxes

Yes. @AdrianoLuiz is correct
You can use groups like this

7 posts were split to a new topic: Filtering data with a checkbox

11 posts were split to a new topic: Filtering data with a checkboxes

Hi,
Same issue for me. My query contains several tables and there are several conditions in addition to the filter condition. Any idea please ?

The part you want to pay attention to is here:

That should help you.

The example works perfectly on a numeric type field. In my case, the field type is SET and it works if the record contains only one value. Thank you in advance for your help.

Hi everyone, any idea to solve my issue ?

Any chance you could try give way more information and screenshots so I can try get a better idea of which filters are and are not working.

Hi psweb,
Thanks for your reply.
The screenshot below is the representation of my table which has 2 fields:

  • id: type smallint, ai
  • Casques audios connecteurs: set type, the values are: Non applicable,Prise 2.5 mm,USB-C,1, Prise 6.35 mm, 1

12 records have been entered as you can see.


I want to filter the “Casques audios connecteurs” column. By using “IN” in the conditions, it displays only the records which have only one value. It ignores all records that contain more than one value in the “Headphones connector” field even if the value that is checked is one of them.


With “CONTAINS”, it displays all the records which contain the selected value.
3

But as soon as you check a 2nd value, it displays only the records which contain these 2 values and ignores the records which contain only one of these 2 values. And so on.
3bis
3bis2

Ok, makes sense so far, last thing, could you paste the code used in your checkbox group here, then I will have enough info to test on my end. I have only ever used the IN operator with similar data, in other words 1,2,3,4,5,6 etc, so just wondering how yours works with the SET of values, but will test it out when i see your checkbox group code.

1 Like

I had a similar scenario and took the decision to switch to a many-to-many table for the values of the checkboxes as that is much easier to work with and more flexible. Would you be able to make the same change?

The table structure would be something like…

RecordID (int, index, ai)
ProductID (int)
FeatureID (int)

Then you can easily make the searches and other functions.

I cant make it work like that either, @sitestreet is right, best to change to a different database solution, then it’s easy.

I have too many tables and it will take me a long time if I have to take this new approach. Thank you anyway for your effort, I will continue to check on my side.

OK, but I was in the same position and got a colleague to write a script to convert all the fields which contained the piped data into separate records in the many-to-many so it wasn’t too big a job.

Ok, keep me posted for the script, I will see on my side if it is to execute it in my case, thx again

The script was completely custom to our requirements so there’s no point in posting it. However, it basically reads through the existing data, splits the fields which had multiple values (pipe separated) and then inserts the new records and includes the relationships. It took a bit of time to write (a few hours) but was very complex. However, when it ran it processed it all in seconds. I needed to do it this way as I was developing a new site where the old site data needed to be migrated so I had to do the migration several times. Hope that helps.

Noted, thx

1 Like

A post was split to a new topic: How to animate dynamic data?

Hi Teodor

I followed every step in your tutorial «Filtering Database Query with Multiple Checkboxes» and that works perfectly. Now my issue is that some records of my database have multiple categories. I separated those category-numbers with commas. Those records don’t show up when filtering with the checkboxes. Can you help me?

Thank you very much for your response.