# Shotgun subquery request

**URL:** <https://community.shotgridsoftware.com/t/shotgun-subquery-request/8997>\
**Category:** Pipeline Integrations\
**Created:** [June 11, 2020, 12:32pm UTC](https://community.shotgridsoftware.com/t/shotgun-subquery-request/8997 "2020-06-11T12:32:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chistof](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@chistof](https://community.shotgridsoftware.com/u/chistof)\
**Post date:** [June 11, 2020, 12:32pm UTC](https://community.shotgridsoftware.com/t/shotgun-subquery-request/8997/1 "2020-06-11T12:32:00Z")

</div>

Hi,

I couldn’t figure from the documentation how to make a query that gets me in one single requests all versions of a project and the shots data. The entity element gives shot name and id but I would like to get more of the Shot entity fields in there.

This should be an easy thing with usual database but through Shotgun API I can’t find the syntax to do that sort of request in one go. Can anyone spare an example of what the fields parameter would be when calling the find() method ?

Thanks  
Chris

---

<div class="post-metadata">

**Author:** ![tommy.kiser](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/tommy.kiser/32/237_2.png) [@tommy.kiser](https://community.shotgridsoftware.com/u/tommy.kiser)\
**Post date:** [June 11, 2020, 10:07pm UTC](https://community.shotgridsoftware.com/t/shotgun-subquery-request/8997/2 "2020-06-11T22:07:27Z")

</div>

Hi @chistof, thanks for posting, and welcome to the :shotgun: forums!

You can reference fields from a linked entity using dot syntax, like this:  
`sg_task.Task.step.Step.id`  
This references the `id` field on the Pipeline Step entity record, which the Task entity record listed in the `sg_task` field is linked to.

To break it down a bit further:  
`sg_task` is a field (perhaps on a Version entity record) that links to a Task entity record  
`Task` references the entity type of this linked entity record  
`step` is a field on Tasks, linking to a Pipeline Step entity record  
`Step` references the entity type of this next linked entity record  
`id` is the unique ID field on the linked Pipeline Step entity record

See the [API Reference doc on Shotgun.find](https://developer.shotgunsoftware.com/python-api/reference.html#shotgun_api3.shotgun.Shotgun.find) for more details.

To get a field from a Shot record linked to a Version, you might do a find() on the Version entity that includes this field reference:  
`entity.Shot.code`

Hopefully that gets you the data you need. Beyond that, if there’s no direct linkage from the entity you are querying, you’d need to do a separate call to find data from another entity.

---

<div class="post-metadata">

**Author:** ![chistof](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@chistof](https://community.shotgridsoftware.com/u/chistof)\
**Post date:** [June 13, 2020, 8:18pm UTC](https://community.shotgridsoftware.com/t/shotgun-subquery-request/8997/3 "2020-06-13T20:18:28Z")

</div>

> [@tommy.kiser](#):
>
> ``
> 
> Hopefully that gets you the data you need. Beyond that, if there’s no dire

Perfect! Thanks!
