【发布时间】:2017-05-25 21:11:34
【问题描述】:
$get_duplicate=DB::select('select * from student_info a join ( select first_name, last_name, dob from student_info group by first_name, last_name, dob having count(*) > 1 ) b on a.first_name = b.first_name and a.last_name = b.last_name and a.dob = b.dob join participant_info on participant_info.id = a.participant_id order by a.first_name ASC');
如何将此查询转换为 Eloquent 格式。
这是我的模型。
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class StudentInfo extends Model
{
//
public $timestamps = true;
protected $table = 'student_info';
protected $guarded = array();
public function student_participant_det(){
return $this->hasOne('App\Model\ParticipantInfo', 'id','participant_id');
}
}
请帮我把它转换成 Eloquent 格式
【问题讨论】:
-
让我们看看您的模型及其关联关系。
-
'StudentInfo' 是一个模型和 hasOne('App\Model\ParticipantInfo', 'id','participant_id'); } 我可以通过这个函数获取相关的参与者信息
-
请在您的问题中输入任何相关代码,而不是在 cmets 中。
-
现在你能帮帮我吗??
-
你能不能也显示
ParticpantInfo。
标签: php mysql laravel subquery laravel-query-builder