I am now trying to filter a query using the values in the JSON field but without success. I am aware that I have to use “IN” and I have tried with and without split but no success. I have the filter parameter set as an array, should this be an object?
So, if kb_tagged contains “2, 5, 8” you want to check if any of these values (2 or 5 or 8) are in the filter array ?
Or all of the values (2 and 5 and 8) are in the filter array?
Please think of what you are trying to do and tell us so we can answer accordingly
Clear the arrayList (I just wanted to copy the schema, we don’t need the data)
I add a repeat with expresion the step-1 query (loop throught the table’s products)
Set Value tags_Array and gave it the current repeat’s prd_Tags column value
I create a switch and set it to false (this is to check if the record is already added to the arrayList)
I add inside the repeat one more repeat to repeat through each product’s tags (JSON)
(here I explain that you could skip step 5 and set now the repeat straight to the prd_Tags column, but just like to see the setValue steps and know what I’m doing)
I add a condition to check when to add the current product to the arrayList.
If switch == false (the product has not been already added to arrayList) and$_GET.filtertags,contains($value) (filter contains the current product’s tag)
if the conditions are met add the current repeat’s product to the arrayList
set the switch to true in order not to add again the same product
Closing all all repeats, we get the arrayList and this is the final filtered query that we are going to use client-side to list our products (THIS IS THE ONLY STEP/VALUE THAT HAS OUTPUT ticked)
Now I realized that if no filter is set the arrayList(new query) will be empty…
You can avoid this and return all the records of the table if you add a condition after step-2 and check if filter has value.
Enclose all steps 4-10 inside the if and leave step-11 outside the if statement (so we have in both cases the arrayList to list our records client-side)