title: How do I get the result of two select statement in a single row?
body: <p>I am using two select statments in a php page as follows:</p>
  
  <pre><code>$num1 = mysql_query("SELECT SId FROM mtable WHERE Pathogen='$pathogen1' &amp;&amp; Topic='$topic1' &amp;&amp; Indicator='$ind1' &amp;&amp; IndicatorSubGroup='$subind1' ");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$num2 = mysql_query("SELECT SId FROM mtable WHERE Pathogen='$pathogen2' &amp;&amp; Topic='$topic2' &amp;&amp; Indicator='$ind2' &amp;&amp; IndicatorSubGroup='$subind2' ");
  </code></pre>
  
  <p>at present the result is displayed using separate while loops as follows</p>
  
  <pre><code>while($nval=  mysql_fetch_array($num1))
  {
      $vv=$nval['SId'];
  
      $result = mysql_query("SELECT * FROM mtable WHERE SId='$vv'");
  
      while($row = mysql_fetch_array($result))
      {
          print "&lt;tr height='18'&gt;";
          print "&lt;td width=200 align=left&gt;" . $row['Country'] . "&lt;/td&gt;";
          print "&lt;td width=70 align=center&gt;" . $row['MidEstimate'] . "&lt;/td&gt;";
          print "&lt;td width=70 align=center&gt;" . $row['LowEstimate'] . "&lt;/td&gt;";
          print "&lt;td width=70 align=center&gt;" . $row['HighEstimate'] . "&lt;/td&gt;";
          print "&lt;td width=89 align=center&gt;" . $row['StudyLocation'] . "&lt;/td&gt;";
          print "&lt;td width=139 align=center&gt;" . $row['ReferenceID'] . "&lt;/td&gt;";
          print "&lt;td width=89 align=center&gt;" . $row['Quality'] . "&lt;/td&gt;";
          print "&lt;td width=89 align=center&gt;" . $row['Relevance'] . "&lt;/td&gt;";
          print "&lt;td width=61&gt;&lt;a href='/sites/default/files/popupboxCD.php?SId=$vv' onClick='openpopup(this.href);return false;'&gt;".$row['Info']."&lt;/a&gt;&lt;/td&gt;";
          print "&lt;/tr&gt;";
          print "&lt;tr height='1'&gt;&lt;td colspan='9' style='padding:0'&gt;&lt;hr size='0.5' color='#CCCCCC' noshade='noshade' /&gt;&lt;/td&gt;&lt;/tr&gt;";
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$num2 = mysql_query("SELECT SId FROM mtable WHERE Pathogen='$pathogen2' &amp;&amp; Topic='$topic2' &amp;&amp; Indicator='$ind2' &amp;&amp; IndicatorSubGroup='$subind2' ");
  print $num2;
  
  print "&lt;table border='0' width='875' align='center'&gt;
  
  &lt;tr&gt;&lt;td colspan=5 height=10&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
      &lt;td width='200' bgcolor='#99CCF5' align='center'&gt;&lt;b&gt;Country&lt;/b&gt;&lt;/td&gt;
      &lt;td width='70' bgcolor='#99CCF5' align='center'&gt;&lt;b&gt;Mid&lt;/b&gt;&lt;/td&gt;
      &lt;td width='70' bgcolor='#99CCF5' align='center'&gt;&lt;b&gt;Low&lt;/b&gt;&lt;/td&gt;
      &lt;td width='70' bgcolor='#99CCF5' align='center'&gt;&lt;b&gt;High&lt;/b&gt;&lt;/td&gt;
      &lt;td width='89' bgcolor='#99CCF5' align='center'&gt;&lt;b&gt;Study Location&lt;/b&gt;&lt;/td&gt;
      &lt;td width='139' bgcolor='#99CCF5' align='center'&gt;&lt;b&gt;Reference&lt;/b&gt;&lt;/td&gt;
      &lt;td width='89' bgcolor='#99CCF5' align='center'&gt;&lt;b&gt;Quality&lt;/b&gt;&lt;/td&gt;
      &lt;td width='89' bgcolor='#99CCF5' align='center'&gt;&lt;b&gt;Relevance&lt;/b&gt;&lt;/td&gt;
      &lt;td width='61' &gt;&lt;/td&gt;
  &lt;/tr&gt;";
  
  while($nval=  mysql_fetch_array($num2))
  {
      $vv=$nval['SId'];
  
      $result = mysql_query("SELECT * FROM mtable WHERE SId='$vv'");
  
      while($row = mysql_fetch_array($result))
      {
          print "&lt;tr height='18'&gt;";
          print "&lt;td width=200 align=left&gt;" . $row['Country'] . "&lt;/td&gt;";
          print "&lt;td width=70 align=center&gt;" . $row['MidEstimate'] . "&lt;/td&gt;";
          print "&lt;td width=70 align=center&gt;" . $row['LowEstimate'] . "&lt;/td&gt;";
          print "&lt;td width=70 align=center&gt;" . $row['HighEstimate'] . "&lt;/td&gt;";
          print "&lt;td width=89 align=center&gt;" . $row['StudyLocation'] . "&lt;/td&gt;";
          print "&lt;td width=139 align=center&gt;" . $row['ReferenceID'] . "&lt;/td&gt;";
          print "&lt;td width=89 align=center&gt;" . $row['Quality'] . "&lt;/td&gt;";
          print "&lt;td width=89 align=center&gt;" . $row['Relevance'] . "&lt;/td&gt;";
          print "&lt;td width=61&gt;&lt;a href='/sites/default/files/popupboxCD.php?SId=$vv' onClick='openpopup(this.href);return false;'&gt;".$row['Info']."&lt;/a&gt;&lt;/td&gt;";
  
          print "&lt;/tr&gt;";
          print "&lt;tr height='1'&gt;&lt;td colspan='9' style='padding:0'&gt;&lt;hr size='0.5' color='#CCCCCC' noshade='noshade' /&gt;&lt;/td&gt;&lt;/tr&gt;";
      }
  }
  </code></pre>
  
  <p>I would like to know if there's any way to merge these two table into single table?</p>
  
  <p>The result should look like this:</p>
  
  <blockquote>
    <p>Value1(common to both query., eg.country), Value2(from 1st query), Value2(from 2nd query)</p>
  </blockquote>
  
  <p>I got only a single table in mysql which both query show results.</p>
  
  <hr>
  
  <p>I am sorry my question confuses all. I am Lotus Notes Developer and not a PHP. So I am only a novice user in sql.</p>
  
  <p>Here I repeat my query again...</p>
  
  <p>At present I got two tables display result from two queries from a single table. I want to mix these result in a single table ?</p>
  
  <p>That is my new table must have three columns. First with common value from both tabels and second column from first table second column and third column from second table second column. Second and third column in new table is dispalying data from same column from the main mysql data.</p>
  
  <p>Hope this makes much better, thanx for all the suggestion. I will try this myself and if get succeed I will post it here.</p>