There are countless examples on the forum already of "building up a query", search first, study examples in docs, and then show what you tried, if you still can't get it.
Jul 31, 2017
5
Level 1
Laravel Query
I want to build a query in laravel from the given SQL query.
select
if(count(*) = 0, 'insert', if(count(*) = 1, 'update', if(count(*) > 1, 'multiple records found',
'nothing'))) as required_action
from
test_importer
where 1
and record_id = 1881
and date_time = "1999-21-19 22:33:18";
Level 1
This one helped me.
$users = DB::select('select if(count(*) = 0, \'insert\', if(count(*) = 1,
\'update\', if(count(*) > 1, \'multiple\', \'nothing\'))) as required_action from
test_importer where record_id = ? and date_time = ? ',
[$row['record_id'],$row['date_time']]);
Please or to participate in this conversation.