質問

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