# create sql with 2 table

**URL:** <https://forum.djangoproject.com/t/create-sql-with-2-table/3205>\
**Category:** Using Django\
**Created:** [June 29, 2020, 6:08pm UTC](https://forum.djangoproject.com/t/create-sql-with-2-table/3205 "2020-06-29T18:08:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![junaooaks](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/junaooaks/32/1607_2.png) [@junaooaks](https://forum.djangoproject.com/u/junaooaks)\
**Post date:** [June 29, 2020, 6:08pm UTC](https://forum.djangoproject.com/t/create-sql-with-2-table/3205/1 "2020-06-29T18:08:19Z")

</div>

hey guy I’m new with python  
how I create filter to return query with relationship with another table

like: return name and lastName if table\_id = 1

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 30, 2020, 12:28am UTC](https://forum.djangoproject.com/t/create-sql-with-2-table/3205/2 "2020-06-30T00:28:30Z")

</div>

A good place to start is with the appropriate documentation, in this case, the query documentation on [Retrieving objects](https://docs.djangoproject.com/en/3.0/topics/db/queries/#retrieving-objects), the [Lookup API Reference](https://docs.djangoproject.com/en/3.0/ref/models/lookups/#module-django.db.models.lookups), and the [Related Objects Reference](https://docs.djangoproject.com/en/3.0/ref/models/relations/#related-objects-reference).

If you’re not comfortable with these topics, then I’d recommend going back to basics and working your way through either or both of the official [Django Tutorial](https://docs.djangoproject.com/en/3.0/intro/tutorial01/), and the [Django Girls Tutorial](https://tutorial.djangogirls.org/en/#django-girls-tutorial).

Ken

,
