I want to pull columns from two different tables next to each other.
I have php code as below :
<table>
<tr>
<th>Date</th>
<th>Performance A </th>
<th>Performance B </th>
</tr>
$sql = "select date, Aperformance from table1 group by date";
$sql1 = "select date, Bperformance from table2 group by date";
$result = mssql_query($sql);
while ($column = mssql_fetch_array($result))
{
echo "<tr><td>".$column[0]."</td>";
echo "<td>".$column[1]."</td></tr>";
}
And this produces output as below :
Date | Performance A | Performance B
01/05/12 | 40% |
02/05/12 | 30% |
03/05/12 | 25% |
Now I want to fill up the third column from query $sql1. I don’t want date column from $sql1, the second column Bperformance needs to put in here. How I can do that?
Assuming both queries return the same number of rows, you could simply do:
If the queries return different sized result sets, then you’ll have do some extra work.