PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table applicants ( id int, created_at int ); insert into applicants values (1, 0), (2, 100); create table applicant_apps ( id int, applicant_id int, created_at int ); insert into applicant_apps values (1, 1, 5000), (2, 2, 5100); update applicants a join applicant_apps aa on aa.applicant_id = a.id set a.created_at = aa.created_at where a.created_at = 0;
Copy Clear
Copy Format Clear
<?php // Select using Laravel $db::table('applicants as a') ->where( $db::raw("`a`.`created_at`"), 0) ->join('applicant_apps as aa', 'aa.applicant_id', '=', 'a.id') ->update([ 'a.created_at' => $db::raw("`aa`.`created_at`") ]) ; $data = $db::table('applicants')->get(); print_r($data);
Show:  
Copy Clear