In this video, we'll look at Subqueries in Django. We'll see how to use subqueries in annotations, filter statements and with the Exists subclass.
Subqueries can be useful for performing these operations on complex related information, and can exist in the SELECT and WHERE expressions (among others) of an SQL SELECT Query.
☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
https://ko-fi.com/bugbytes
📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
00:58 Subqueries in SQL
04:48 Writing Subqueries with Django
16:58 Exists subqueries in Django
▶️ Full Playlist:
https://www.youtube.com/playlist?list=PL-2EBeDYMIbQXKsyNweppuFptuogJe2L-
𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: https://bugbytes.io/posts/
👾 Github: https://github.com/bugbytes-io/django-orm-series
🐦 Twitter: https://twitter.com/bugbytesio
📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Django Subqueries: https://docs.djangoproject.com/en/4.2/ref/models/expressions/#subquery-expressions
Django Exists object: https://docs.djangoproject.com/en/4.2/ref/models/expressions/#exists-subqueries
#python #django #webdevelopment #database #sql