title: Using a subquery in 'FROM' in gorm
body: <p>I would like to know how I can use a subquery in FROM clause using gorm. It would look like the following:</p>
  
  <pre><code>SELECT * FROM 
  (
    SELECT foo.*
    FROM foo
    WHERE bar = "baz"
  ) AS t1
  WHERE t1.id = 1;
  </code></pre>
  
  <p>I have built the subquery using golang:</p>
  
  <pre><code>db.Model(Foo{}).Where("bar = ?", "baz")
  </code></pre>
  
  <p>But how can I use this as a subquery in <code>FROM</code>?</p>
  
  <p>If there is a method that turns a gorm query into a SQL string, then I can simply plug that string into a raw SQL. But there does not seem to be such method. Any suggestions?</p>