Skip to content

Instantly share code, notes, and snippets.

@marlocorridor
Created February 17, 2023 01:00
Show Gist options
  • Save marlocorridor/ab1b0c7566698383f0748f3ae85bbc4f to your computer and use it in GitHub Desktop.
Save marlocorridor/ab1b0c7566698383f0748f3ae85bbc4f to your computer and use it in GitHub Desktop.
Laravel Raw DB query whereIn equivalent on JSON column
<?
DB::table('transactions')
->select(
'id',
DB::raw('meta->"$.target_units" as target_units'),
DB::raw('"9864a4b0-ac8a-43bc-a8cf-c10c6e2da09c" MEMBER OF(meta->"$.target_units") as hit')
)
->where('hit', true)
->get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment