Reputation: 14578
I have a table like this-
webinars
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?
Upvotes: 2
Views: 2684
Reputation: 6236
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);
Upvotes: 4