MySQL json_object and json_arrayagg with group by not working as expected

I’ve a many to many relationship with this tables Table assets: id name other fields 19 asset 1 … 20 asset 2 … … … … Branches table: id name other fields 1 branch 1 … 2 branch 2 … … … … branch_r_asset: branch_id asset_id 1 1 1 2 2 14 n n I… Read More MySQL json_object and json_arrayagg with group by not working as expected

Access JSON column

How can I access values in the status and date columns stored as JSON? Please, have a look at an example row below. {"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}} >Solution : Demo: set @j = ‘{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}}’; select json_extract(@j, ‘$."1".status’) as status; +——–+ | status | +——–+ | true | +——–+ In this case, it may be unexpected that you need… Read More Access JSON column

Looping through an array in SQL column

I have a SQL table that looks something like this: | ID | Value | | — | —————————————————– | | 1 | {"name":"joe", "lastname":"doe", "age":"34"} | | 2 | {"name":"jane", "lastname":"doe", "age":"29"} | | 3 | {"name":"michael", "lastname":"dumplings", "age":"40"}| How can I using SQL select function, select only the rows where "age" (in value… Read More Looping through an array in SQL column