MedicOneSystems / livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS
https://livewire-datatables.com/
MIT License
1.19k stars 258 forks source link

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

Open sheepbild opened 2 years ago

sheepbild commented 2 years ago

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 commented 2 years ago

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

Table Functions :

Table Function Sub Group :

Table Function Group :

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')