<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vignesh Ponraj on Medium]]></title>
        <description><![CDATA[Stories by Vignesh Ponraj on Medium]]></description>
        <link>https://medium.com/@vigneshponraj97?source=rss-d55d0a1b09fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7iTA2bizXEhC6qo9JIZjRA.png</url>
            <title>Stories by Vignesh Ponraj on Medium</title>
            <link>https://medium.com/@vigneshponraj97?source=rss-d55d0a1b09fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 22:03:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vigneshponraj97/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[JOIN: SQL’s Power Move (and How It Can Mess You Up)]]></title>
            <link>https://medium.com/@vigneshponraj97/join-sqls-power-move-and-how-it-can-mess-you-up-c966bf1c00fc?source=rss-d55d0a1b09fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/c966bf1c00fc</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[syntax]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Vignesh Ponraj]]></dc:creator>
            <pubDate>Thu, 29 May 2025 02:55:22 GMT</pubDate>
            <atom:updated>2025-05-29T02:55:22.153Z</atom:updated>
            <content:encoded><![CDATA[<h4>A dive into SQL JOINs — why they’re magical, and when they quietly flip the script.</h4><p>I once wrote a query that returned ~10,000 rows instead of the 120 I was expecting.</p><p>No error. No warning. Just a little JOIN clause ruining my afternoon like it was on a mission.</p><p>If you’ve ever peeked into an SQL query with JOIN and felt like you were watching a perfectly curated query return chaos, welcome to my TED Talk.</p><p>Let’s unpack JOINs — what they are, why they’re powerful, and how they can quietly turn your data into a nightmare of duplicates.</p><h3>So, what is a JOIN, really?</h3><p>At its heart, a JOIN is SQL’s way of saying:</p><p><em>“Hey, these two tables seem like they should be friends. Let’s link them up.”</em></p><p>Imagine you’ve got two tables:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*VK-GIIzkKy5WkH1XAbNPzg.png" /><figcaption>Users Table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*rflIbrZQ63zWrUe4yMwSnA.png" /><figcaption>Orders Table</figcaption></figure><p>You want to know what each user ordered:</p><pre>SELECT Users.name, Orders.item  <br>FROM Users  <br>JOIN Orders ON Users.id = Orders.user_id;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*4_bNdrzIA1WMaZCkDXwhfA.png" /><figcaption>Expected Output</figcaption></figure><p>Boom. Beautiful, right?</p><p>Next let’s look at when JOINs start acting up.</p><h3>The Classic Tech Blunders</h3><ul><li>Never push to prod on a Friday</li><li>Never ask ChatGPT for prenup advice</li><li><strong>Never JOIN without checking your cardinality</strong></li></ul><p>Let’s dig into that last one.</p><h4><strong>1. The Accidental Cross Join</strong></h4><p>Forgetting the ON clause induces chaos:</p><pre>SELECT * FROM Users JOIN Orders;</pre><p>This gives you a <strong>Cartesian product</strong> — every row in Users pairs with <em>every</em> row in Orders. In our example? 2 x 3 = 6 rows. In production? Could be millions. And yes, your server might cry.</p><h4><strong>2. The Many-to-Many Mayhem</strong></h4><p>This one’s sneakier.</p><p>Let’s say you have two tables:</p><ul><li><em>Students</em> with multiple enrollments</li><li><em>Courses</em> with multiple enrolled students</li></ul><p>If you JOIN them on course_id, you’re suddenly creating a row for <strong>every unique pairing</strong> of student-course match.</p><p>Multiple students per course * multiple courses per student = <strong>exponential row explosion</strong>.</p><h3><strong>Final Tip/Trick</strong></h3><p>Always start your JOIN experiments with:</p><pre>LIMIT 10</pre><p>And if you suspect something, run a COUNT(*) grouped by key to check how many matches you’re actually pulling:</p><pre>SELECT user_id, COUNT(*)  <br>FROM Orders  <br>GROUP BY user_id  <br>ORDER BY COUNT(*) DESC;</pre><p>It’s the SQL equivalent of “measure twice, cut once.”</p><p>Your queries and future self will thank you.</p><p>#SQL #DataEngineering #TechHumor</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c966bf1c00fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>