2

I have a table like this-

webinars

enter image description here

I want to have a query in Laravel Query Builder like this-

    // Base Query
    $baseQuery = DB::table('webinars')
        //->join('users', 'panelists.user_id', '=', 'users.id')
        ->select(
            'id',
            'title',
            'description',
            'hosts',
            DB::raw('concat(starts_on, ' ', timezone) as starts'),
            'duration',
            'created_at'
        )
        ->where('user_id', '=', $user_ID);

And getting error for-

     DB::raw('concat(starts_on, ' ', timezone) as starts')

I need it because I want something like =>

today JPN

if starts_on=today and timezone='JPN'

Can anyone pleae help?

1 Answer 1

4

DB::raw('concat(starts_on, ' ', timezone) as starts')

:- You have added single quote inside single quote.

You can try this:

// Base Query
$baseQuery = DB::table('webinars')
    //->join('users', 'panelists.user_id', '=', 'users.id')
    ->select(
        'id',
        'title',
        'description',
        'hosts',
        DB::raw('concat(starts_on, " ", timezone) as starts'),
        'duration',
        'created_at'
    )
    ->where('user_id', '=', $user_ID);
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.