<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: WeenAIthDev</title>
    <description>The latest articles on DEV Community by WeenAIthDev (@weenaithdev).</description>
    <link>https://dev.to/weenaithdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3910009%2F14b8ecb6-78b7-481d-9dbe-6f55ffcc6b45.jpg</url>
      <title>DEV Community: WeenAIthDev</title>
      <link>https://dev.to/weenaithdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/weenaithdev"/>
    <language>en</language>
    <item>
      <title>Understanding SQL query structure</title>
      <dc:creator>WeenAIthDev</dc:creator>
      <pubDate>Wed, 13 May 2026 10:14:29 +0000</pubDate>
      <link>https://dev.to/weenaithdev/understanding-sql-query-structure-4hei</link>
      <guid>https://dev.to/weenaithdev/understanding-sql-query-structure-4hei</guid>
      <description>&lt;p&gt;This is basically SQL’s version of BODMAS/PEDMAS.&lt;/p&gt;

&lt;p&gt;We &lt;em&gt;write&lt;/em&gt; SQL one way…&lt;br&gt;
but SQL &lt;em&gt;executes&lt;/em&gt; it differently.&lt;/p&gt;

&lt;p&gt;The golden rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;F/JWGBHSOL/O
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looks gibberish at first.&lt;br&gt;
Actually very important.&lt;/p&gt;


&lt;h1&gt;
  
  
  How SQL Executes Queries
&lt;/h1&gt;
&lt;h2&gt;
  
  
  F/J → FROM / JOIN
&lt;/h2&gt;

&lt;p&gt;Build the dataset.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FROM → grab the main table&lt;/li&gt;
&lt;li&gt;JOIN → combine other tables&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  W → WHERE
&lt;/h2&gt;

&lt;p&gt;First filter.&lt;/p&gt;

&lt;p&gt;Removes rows that don’t match conditions.&lt;/p&gt;


&lt;h2&gt;
  
  
  GB → GROUP BY
&lt;/h2&gt;

&lt;p&gt;Create groups from rows.&lt;/p&gt;

&lt;p&gt;Turns row-level data into grouped data.&lt;/p&gt;


&lt;h2&gt;
  
  
  H → HAVING
&lt;/h2&gt;

&lt;p&gt;Second filter.&lt;/p&gt;

&lt;p&gt;But this time for groups, not rows.&lt;/p&gt;


&lt;h2&gt;
  
  
  S → SELECT
&lt;/h2&gt;

&lt;p&gt;Pick the final columns/results to display.&lt;/p&gt;


&lt;h2&gt;
  
  
  O → ORDER BY
&lt;/h2&gt;

&lt;p&gt;Sort the final output.&lt;/p&gt;


&lt;h2&gt;
  
  
  L/O → LIMIT / OFFSET
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;LIMIT → how many rows to show&lt;/li&gt;
&lt;li&gt;OFFSET → how many rows to skip&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  Important Thing
&lt;/h1&gt;

&lt;p&gt;We WRITE SQL like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But SQL THINKS like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;HAVING&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understanding this makes SQL much less confusing.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://builtin.com/data-science/sql-order-of-execution?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;SQL ORDER OF EXECUTION&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
