Search through JSON / Finding values in JSON

Search for a value within a JSON string in a database column.

Overview

The user needed to delete database rows where a specific value appears inside a JSON-encoded string stored in a column.
Use a SQL LIKE condition with wildcards to match the value inside the JSON string.

Answered
ChronoForms v7
lu luken 09 Nov, 2020
Hey there,
I'm trying on the following:

Let's say I select the value
Peter
in a dropdown. Value and Text is identical.

I read in a table which has a specific column with a json encoded string. Each dataset / row has a different string, so for example:
row with id 1: ["Sarah", "Peter", "Tom"]
row with id 2: ["Tobi", "Jane", "David", Ellis"]

What I like to do is, just to delete the datasets where the value Peter (or whatever I select in the dropdown) occures.
So, referring the example above: Just row with id 1 will be deleted.

I know how to delete datasets through setting "Where conditions" but how can I so-to-say "search" through the json string for each dataset?

Any idea?
Max_admin Max_admin 11 Nov, 2020
Answer
1 Likes
try to use LIKE:
LIKE %"Peter"%
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.