문제

Actually I want to use below query:

Select userid,username from users where userid not in (Select distinct fkuserid from staff);

So for that I have used:
$result=DB::table('users') -> whereNOTIN('userid',DB::table('staff') -> distinct() -> get(array('fkuserid'))) -> get(); 

but it is giving error of Object of class stdClass could not be converted to string.

도움이 되었습니까?

해결책

I'm working on L3, which lacks what I've now found in L4 docs. Try:

$result=DB::table('users') -> whereNotIn('userid',DB::table('staff') -> distinct() -> lists('fkuserid')) -> get();

The lists() method should (I think) return only an array of ids as I wrote in comment.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top