How to get data after using joinWith()

I have two tables one is ‘articles’ and second is ‘organization_articles’

I want to get all disabled articles from organization_articles table along with those articles which are not present in organization_articles.

$query = Articles::find();
$query->Joinwith([‘orgArticles’]);
$query->andFilterWhere([’=’,‘organization_articles.oar_art_status’ ,$this->art_status,]);

If art_id is the foreign key:

$query = Articles::find()
->joinWith([‘orgArticles’])
->andWhere([‘organization_articles.oar_art_status’ => $this->art_status])
->andWhere('organization_articles.art_id IS NULL');

There is no null art_id in organization_articles. Basically organization_articles create conditionally.

You can’t get records from table if doesn’t exist. You are referring to same table twice in your statement.

Basically joinWith() returns only matched values from articles and i also want unmatched values from articles

Then use with() instead of joinWith() it does not make difference in you case, by default joinWith() is left join. Keep your andFilterWhere() inside joinWith(). If you check your current query you will see this condition after join this is what restricts records from articles.

Try this instead,

$query = Articles::find()->with(['orgArticles' => function ($q) {
    $q->andFilterWhere(['oar_art_status'  => $this->art_status]);
}]);