best way to get records NOT IN related table?

Hi Guys!

Lets say we have 2 related tables for example:

user and setting

Now I want to list all users which have no settings…

With mySQL I could do it for example like this:

$sql = 


  SELECT u.* FROM user AS u

  LEFT JOIN  setting AS s

  ON = s.user_id

  WHERE s.user_id IS NULL 


$users = User::findBySql($sql)->all();

Questions are:


[*]Should I keep it that way?

[*]Or is there a better Yii2-way to do this?

[*]If yes: how would you solve this? (could you please give example?)


I found for example this:

But was to dumb to get it working… :rolleyes:

Thank you and best regards

also you can create a relation in the model with that condition and call it like other relations