Ad
Laravel Select Rows Has A Column Including The Input Variable
I have a data variable named $staff_id and I have a notice table in database, in table has a "can_see" column, this column contains data as an id string separated by commas, I want to get the rows has $staff_id of that string, i want to use the Laravel query builder and I don't want to use the Stored procedure.
DB::table('tasks')->where("staff_id in can_see column!!")->get();
Ad
Answer
You can try this
DB::table('tasks')->whereRaw(DB::raw('find_in_set("'.$staff_id.'", can_see) > 0'))->get();
If you save your values as '6','7','8','9','10'
, you could easily use LIKE
to filter the records.
DB::table('tasks')->where('order_id', 'LIKE', "%'".$staff_id."'%")->get();
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad