title: How to use SQL query to define table in dbtable?
body: <p>In <a href="http://spark.apache.org/docs/latest/sql-programming-guide.html#jdbc-to-other-databases" rel="noreferrer">JDBC To Other Databases</a> I found the following explanation of <code>dbtable</code> parameter: </p>
  
  <blockquote>
    <p>The JDBC table that should be read. Note that anything that is valid in a FROM clause of a SQL query can be used. For example, instead of a full table you could also use a subquery in parentheses.</p>
  </blockquote>
  
  <p>When I use the code: </p>
  
  <pre><code>CREATE TEMPORARY TABLE jdbcTable
  USING org.apache.spark.sql.jdbc
  OPTIONS (
    url "jdbc:postgresql:dbserver",
    dbtable "mytable"
  )
  </code></pre>
  
  <p>everything works great, but the following:</p>
  
  <pre><code> dbtable "SELECT * FROM mytable"
  </code></pre>
  
  <p>leads to the error:</p>
  
  <p><a href="https://i.stack.imgur.com/1V3bg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1V3bg.png" alt="enter image description here"></a></p>
  
  <p>What is wrong?</p>