title: Spark sql when joining two or more tables using two select statements
body: <p>This is my statement:</p>
  
  <pre><code>val Porders = sqlContext.sql(
      """SELECT count(STATUS_CD) 
      FROM s_order 
      WHERE STATUS_CD = 'pending' AND ROW_ID IN 
          ( SELECT so.ROW_ID FROM s_order so 
          JOIN s_order_item soi 
          ON so.ROW_ID = soi.ORDER_ID 
          JOIN s_order_type sot 
          ON so.ORDER_TYPE_ID = sot.ROW_ID 
          JOIN s_product sp 
          ON soi.PROD_ID = sp.ROW_ID
          WHERE (sp.NAME like '%VIP%' OR sp.NAME like '%BIZ%' OR sp.NAME like '%UniFi%') 
          AND LOWER(sot.NAME) = 'new install')
      """)
  </code></pre>
  
  <p>I receive the following error:</p>
  
  <pre><code>ERROR : java.lang.RuntimeException: [3.3] failure: identifier expected
  ( SELECT so.ROW_ID FROM s_order so JOIN s_order_item soi 
    ^
  </code></pre>
  
  <p>What could be the reason?</p>