apex – SOQL gives (null ) output for the lookup type field value in salesforce?

I have two objects, Sdf__c and SdfBudget__c. Sdf__c has a lookup field related to the SdfBuget object. I want to fetch values from sdf__c along with budget fields from sdfBudget that match SdfBudget vbu names

But i return (null <object__r) for the field. How to get the value instead of null.

The field has values but its not returning.

suppose the table has the following columns:
Sdf__c
sdf__c with fields

SdfBudget__c
SdfBudget__c with fields

and i need to get the output as follows

enter image description here

Query which i have trid

    List<SdfBudget__c> sdfVbus=new List<SdfBudget__c>();
    sdfVbus=[SELECT budget__c,VBU__c FROM SdfBudget__c WHERE VBU__C != null];
    List<Sdf__c> sdfItems=new List<Sdf__c>();
    for(SdfBudget__c ob:sdfVbus)
    {
        vbuValues.add(ob.VBU__c);
    }
   sdfItems=[SELECT Name,VBU__c,Sdf_Budget__r.Budget__c FROM sdf__c WHERE VBU__c IN :vbuValues];

Read more here: Source link