select c.*,m.title,u.name from comments as c left join messages as m on c.message_id=m.id left join users as u on c.user_id=u.id where c.message_user_id=1;
你这样试试
DB::table('comments as c')
->leftJoin('messages as u','c.message_id','=','m.id')
->leftJoin('users as u','c.user_id','=','u.id')
->where(['c.message_user_id'=>1])
->select('c.*','u.title','u.name)
->get();
1 个回复
人生如梦
赞同来自: Aaron
DB::table('comments as c')
->leftJoin('messages as u','c.message_id','=','m.id')
->leftJoin('users as u','c.user_id','=','u.id')
->where(['c.message_user_id'=>1])
->select('c.*','u.title','u.name)
->get();