Leveraging the 'IN' Operator in a Paged Query Result with JSON Data

Hi @Teodor,

I have prepared the following paged query. The result returned from this query is in the JSON format below. I want to use the “ticket_team_id” from this result in another query using the IN operator. I tried a few attempts with split, but I couldn’t get the desired result. I would greatly appreciate it if you could guide me on the correct way .

Ekran Resmi 2023-09-01 22.39.07

{
"ticket_id": 36,
"ticket_district": 3,
"ticket_water_type": 2,
"ticket_water_pump": "merkez 1 ",
"ticket_equipment_name": null,
"ticket_issue_name": "DENEME ARIZA SEBEBİ",
"ticket_work_name": null,
"ticket_used_spare_part": null,
"ticket_status": 1,
"ticket_status_desc": "İş Emri Oluşturuldu",
"ticket_team_id": "["25","27","29"]",
"ticket_creatorId": 26,
"ticket_LastUpdaterId": null,
"ticket_onCreated": "2023-08-31 15:43:11",
"ticket_onUpdated": null,
"ticket_onClosed": null,
"ticket_ClosedBy": null,
"ticket_onApproved": null,
"ticket_ApprovedBy": null,
"district_name": "YENİŞEHİR",
"water_type": "İÇME SUYU",
"durum": "Kapalı"
}

That’s a string, it should be

"ticket_team_id": ["25","27","29"],

to be properly formatted as an array.

Ekran Resmi 2023-09-01 23.01.39

I have configured it as JSON in MariaDB, but this field is apparently referred to as longtext in MariaDB. I am inserting data with Tagify, but the result returned is in string format, yes.

Actually, my question begins here: What should I do if the result is like this?

@Teodor is this a bug? Or is there something I missed?

I don’t think this is a bug, seem mariadb uses longtext / text field types for JSON data.
What server model are you on? If on nodejs you can try using ticket_team_id.parseJSON()

php server model not nodejs … so I need solution for php

Isn’t your own custom json_decode formatter doing the job?

ahahah i forgot i did it myself
:sweat_smile:

1 Like