---
schema_version: "1"
id: 97d4a25801339c471ac8302055640d5f20428c43477c9f420b69d1ac04a66c13
title: Using Relationship Queries with History Objects
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-soql-sosl/guides/soql-sosl/sforce-api-calls-soql-relationships-query-hist.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-relationships-query-hist.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1b7134c93492ef2fc43a2b08d3f5994f6ff7a1c84f6ca7459a5b22f834f4256f
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# Using Relationship Queries with History Objects

Custom objects and some standard objects have an associated history object that tracks changes to an object record. You can use SOQL relationship queries to traverse a history object to its parent object.

For example, the following query returns every history row for `Foo__c` and displays the name and custom fields of `Foo`:

```soql
SELECT OldValue, NewValue, Parent.Id, Parent.name, Parent.customfield__c
FROM foo__history
```

This example query returns every Foo object row together with the corresponding history rows in nested subqueries:

```soql
SELECT Name, customfield__c, (SELECT OldValue, NewValue FROM foo__history)
FROM foo__c
```
