---
title: "Discussion on \"Correlated Subqueries and Why You Need To Know Them\" | Hashnode"
description: "Discussion on \"Correlated Subqueries and Why You Need To Know Them\". Queries are fun when you understand them!"
url: "https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Correlated Subqueries and Why You Need To Know Them](https://blog.akjn.dev/correlated-subqueries-and-why-you-need-to-know-them?utm_source=hashnode&utm_medium=feed)

Queries are fun when you understand them!

Sep 19, 2023 · 8 min read · blog.akjn.dev  
Read the article

-   [#postgresql](https://hashnode.com/tag/postgresql)
-   [#sql](https://hashnode.com/tag/sql)
-   [#databases](https://hashnode.com/tag/databases)
-   [#software-engineering](https://hashnode.com/tag/software-engineering)
-   [#software-development](https://hashnode.com/tag/software-development)

## Written by

[Akshat Jain](https://hashnode.com/@akjn)

@akjn · India

  
[View profile](https://hashnode.com/@akjn)

Software Engineer at Yugabyte

Backend software engineer from India. Love databases, cloud technologies, and chess.

## Responses 7

Markdown supported · ⌘↵ to post

[Praneeth S](https://hashnode.com/@praneethshankar)

[Sep 23, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650eda8f596d513beec4d382)

Good blog

[Akshat Jain](https://hashnode.com/@akjn)

[Sep 23, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650eda8f596d513beec4d382#reply-650edad3596d513beec4d393)

Glad you liked it! Thank you! :)

[Josef Richberg](https://hashnode.com/@josefrichberg)

[Sep 22, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650cdb20939d972b99323bd3)

Hi Akshat, A correlated subquery would have an inner join like this:

select \* from table1 where exists (select 1 from table2 where table1.col1=table2.col1);

you are connecting via a join within the sub select.

[Md Taqui imam](https://hashnode.com/@taqui786)

[Sep 21, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650bd47a6e010e234b1ce405)

Thank you for your informative post on correlated subqueries! I'm now better able to understand and use them to write more efficient SQL queries.

[Akshat Jain](https://hashnode.com/@akjn)

[Sep 21, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650bd47a6e010e234b1ce405#reply-650bedb28cd3ce237b6ddfff)

Glad to hear that! Thanks! :D

[Md Taqui imam](https://hashnode.com/@taqui786)

[Sep 21, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650bd28d8cd3ce237b6dda39)

Thank you so much for this excellent blog post on correlated subqueries! I'm a SQL developer, and I've always struggled to understand why correlated subqueries are necessary and how to use them effectively. Your post provides a clear and concise explanation of correlated subqueries, along with several examples of how to use them in real-world scenarios.

I especially appreciate the way you highlight the benefits of using correlated subqueries, such as improved performance and readability. Your post has helped me to better understand the power of correlated subqueries and how to use them to write more efficient and effective SQL queries.

I highly recommend this blog post to anyone who wants to learn more about correlated subqueries. Thank you again for sharing your knowledge and expertise with the community!

[Akshat Jain](https://hashnode.com/@akjn)

[Sep 21, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650bd28d8cd3ce237b6dda39#reply-650beda36e010e234b1ce7ab)

Thank you for the kind words! :D

[Ashwani Yadav](https://hashnode.com/@ashwani-iitp)

[Sep 20, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650b1184faf78f211d73bdf0)

you are GOAT! you are Batman, the knight

[Akshat Jain](https://hashnode.com/@akjn)

[Sep 20, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650b1184faf78f211d73bdf0#reply-650b1558faf78f211d73beb2)

😂🙏

[Aashutosh Rathi](https://hashnode.com/@aashutoshrathi)

[Sep 19, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650a07724a3e39112c026529)

Concise. Useful. Brilliant 🐐

[Akshat Jain](https://hashnode.com/@akjn)

[Sep 19, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650a07724a3e39112c026529#reply-650a089d4a3e39112c02655e)

Thank you! :D

[SIGMA DEVELOPER](https://hashnode.com/@sigma793)

[Sep 20, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/650a07724a3e39112c026529#reply-650a7269a0913a10fcc34b02)

[Akshat Jain](https://hashnode.com/@akjn) hlo

[Tanay Maheshwari](https://hashnode.com/@zephyr1804)

[Sep 19, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/6509d0a2a0913a10fcc34116)

Awesome read with great practical application

[Akshat Jain](https://hashnode.com/@akjn)

[Sep 19, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/6509d0a2a0913a10fcc34116#reply-6509deff4a3e39112c0260cf)

Yay, happy to hear that! Thanks! :D

[Shrish Sharma](https://hashnode.com/@shrishcs)

[Sep 19, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/6509cd6e4a3e39112c025ec6)

I love how you describe things sir!

[Akshat Jain](https://hashnode.com/@akjn)

[Sep 19, 2023](https://hashnode.com/posts/correlated-subqueries-and-why-you-need-to-know-them/6509776b6e85b4e1a3475e73/comment/6509cd6e4a3e39112c025ec6#reply-6509dee34a3e39112c0260c5)

Thank you! :D
