php - How to update from subquery using Laravel Query Builder -
update table set id ='999' seq = ( select seq table id null order seq limit 1)
please teach me
using query builder
$subquery = db::table('table') ->select('seq') ->wherenull('id') ->orderby('seq') ->take(1) ->tosql(); $query = db::table('table') ->whereraw("seq = ($subquery)") ->update(['id' => 999]);
raw query:
$sql = 'update table set id = 999 seq = (select seq table id null order seq limit 1)'; db::statement($sql);
Comments
Post a Comment