0

I need laravel query builder to fetch '' as gdate to do union of another query.

example below:

$unionquery = DB::table('mt_task_category')
->whereIn('role_id', [1])
->select('null as gdate', 'null as user_id', 
         'category_id', 'category_name', 
         'null AS timeSum', 'null AS gdfullname', 
         'null AS id', 'null AS pmfullname', 'null AS role_name');

1 Answer 1

1

You could make use of DB::raw()

$unionquery = DB::table('mt_task_category')
                ->select(DB::raw('null AS gdate', 'null AS user_id', 
                        'category_id', 'category_name', 
                        'null AS timeSum' , 'null AS gdfullname', 
                        'null AS id', 'null AS pmfullname', 
                        'null AS role_name'));
                ->whereIn('role_id', [1])
                ->get();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.