livewire-datatables icon indicating copy to clipboard operation
livewire-datatables copied to clipboard

Problem with mysql "IN (...)" when using Column::raw

Open sheepbild opened this issue 3 years ago • 1 comments

Hi,

I tried to use mysql "IN" with Column::raw().

The above mysql query is working properly when using it with DB::select() but doesn't work when used in Column::raw()

SELECT * FROM functions WHERE function_sub_group_id IN
(SELECT id FROM function_sub_groups WHERE function_group = function_group.id)

See the error on Flare : https://flareapp.io/share/95JLqEDP#F92

Do you know how can I deal with it ? Thx

sheepbild avatar Aug 03 '22 16:08 sheepbild

To explain, I've 3 tables which represent 3 levels :

Table Functions :

  • id
  • function_sub_group_id

Table Function Sub Group :

  • id
  • function_group_id

Table Function Group :

  • id

Here, we are in the FunctionGroups datatable, and I want a sortable column where we find a count of the functions attached to it.

Maybe someting like NumberColumn::name('function_sub_groups.functions.id:count')

sheepbild avatar Aug 03 '22 17:08 sheepbild