Setting unknown property when trying to join table I've successfully joined a table to the elements table, however I can't can't seem to add a property so I can use it?

Getting the error Setting unknown property when trying to join table

Entry::find()
    -&gt;addSelect(['craft_event_instances.instance_datetime'])
    -&gt;leftJoin('craft_event_instances', '`craft_event_instances`.`entryId` = `elements`.`id`')


Thanks
You can't set a property of an element in Craft that does not exists in the field layout, as a behavior or as a public/private attribute in the object. Craft/Yii2 will throw an exception because the property instance_datetime probably does not exist.

In order to attach a custom value you have to either create a new element or you have to store this information somewhere else. 

Edit

You could the following as well to fetch your values and store them into a new array

$query = Entry::find();
$columns = $query
    -&gt;addSelect('craft_event_instances.instance_datetime')
    -&gt;innerJoin('craft_event_instances', 'craft_event_instances.entryId = elements.id')
    -&gt;createCommand()
    -&gt;queryAll();
$yourCustomValues = [];
foreach($columns as $key =&gt; $column){
    $yourCustomValues[$column['id']] = $column['instance_datetime'];
    unset($columns[$key]['instance_datetime']);
}
$elements = $query-&gt;populate($columns);