title: SQL "with" clause - Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS
body: <p>I have the following query which works fine:</p>
  
  <pre><code>select a.dataId, a.my_no,  b.my_attribute  from myDB.table_a a left join myDB.table_b b 
  on a.my_no = b.my_no order by dataId
  </code></pre>
  
  <p>However, if I include the <code>with</code> clause like below:</p>
  
  <pre><code>with my_table as (
      select a.dataId, a.my_no,  b.my_attribute  from myDB.table_a a left join myDB.table_b b 
      on a.my_no = b.my_no order by dataId
  )
  
  select * from my_table
  </code></pre>
  
  <p>I got the following error:</p>
  
  <pre><code>Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar.
  </code></pre>
  
  <p>This is confusing ... shouldn't these two queries be identical? What did I do wrong here? (I am using MariaDB server) Thanks!</p>