lundi 12 février 2018

How to query row containing the given element inside a json column Laravel Postgres

Hello all I have a postgresql table that has a json column called agents. See below

SELECT agents FROM cnms_rosters;

result

      agents      
------------------
 [1,13,3,16,15]
 [12,13,14,15,15]
 [11,73,55,16,44]
(3 rows)

This column contains the id of an agent. What I want to do is to query the row or rows that has the specific agent id.

How can I achieve that?

I am currently using Laravel Framework is there any eloquent approach in querying the data? if not how to query it using DB::raw or other query builder.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire