Reputation: 2098
I have on table assets
and I want to update each code
column as 'ASSET000'
+ primary id
of table like below
Asset0001 for id 1
Asset0002 for id 2
Asset0003 for id 3
In mysql query will be
UPDATE assets SET code = concat('ASSET000', id)
How can I write in Laravel
DB::table('assets')->update('code',????)
Upvotes: 1
Views: 44
Reputation: 11083
Using DB::raw()
you can do it like this :
DB::table('assets')->update(['code' => DB::raw( CONCAT('ASSET000', id) )])
Upvotes: 1