title: selecting two different table row data into a row in for loop using pl/sql
body: <p>I have a region in oracle apex to which the data is getting from an pl/sql.</p>
  
  <p>The following is the pl/sql source:</p>
  
  <pre><code>begin    
      for drow in ( select * from books where book_id = :P13_BooK_ID ) loop
          htp.prn('&lt;table border=0&gt;
                &lt;tbody&gt;
                  &lt;tr&gt;
                    &lt;td valign=top&gt;
                        &lt;table border=0&gt;
                &lt;tbody&gt;
                                       &lt;tr&gt;
                    &lt;td &gt;Reporting Period&lt;/td&gt;    
                    &lt;td &gt;' || to_char(drow.REPORTING_PERIOD, 'MM-DD-YYYY') || '&lt;/td&gt;
                  &lt;/tr&gt;   
                   &lt;tr&gt;
                    &lt;td &gt;L Key&lt;/td&gt;    
                    &lt;td &gt;' || drow.L_KEY || '&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                    &lt;td &gt;Name&lt;/td&gt;
                    &lt;td &gt;' || drow.BooK_NAME || '&lt;/td&gt;
                  &lt;/tr&gt;                   
                  &lt;tr&gt;
                    &lt;td &gt;C Type&lt;/td&gt;
                    &lt;td &gt;' || drow.C_TYPE || '&lt;/td&gt;
                  &lt;/tr&gt;                   
                  &lt;tr&gt;
                    &lt;td &gt;E Count&lt;/td&gt;
                    &lt;td &gt;' || drow.E_COUNT || '&lt;/td&gt;
                  &lt;/tr&gt;
                &lt;/tbody&gt;
              &lt;/table&gt;');    
      end loop;
  end;
  /
  </code></pre>
  
  <p>Now I would like to add two more details(principal,director) into this region which are in another table called school and I have a common column in these two tables books,school as books.l_key = school.k_key.</p>
  
  <p>How can I add these two details in the above region and there are many common column names in both the tables so when I tried as:</p>
  
  <pre><code>for drow in ( select * from books b, school s where book_id = :P13_BooK_ID and books.l_key =school.k_key) loop
  </code></pre>
  
  <p>it shows me error </p>
  
  <blockquote>
    <p>ORA-06550: line 4, column 2: PLS-00402: alias required in SELECT list
    of cursor to avoid duplicate column names ORA-06550: line 4, column 2:
    PL/SQL: Statement ignored</p>
  </blockquote>
  
  <p>can someone tell me how can I get these two details to add in the region. Thanks</p>