Possible Duplicate:
how to select two columns from two tables in mysql
I am trying to execute this query but i got different output. I want
to count row from one column(grade
) from table grading
and select
column(level)
from other table info
.
for($i=1; $i<9; $i++)
{
$result = mysql_query("SELECT COUNT(grade),level FROM grading,info WHERE grade = $i");
while ($row = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $row['level'];
echo "</td>";
echo "<td>";
echo $row['COUNT(grade)'];
echo "</td></tr>";
}
}
my database:
level grade
A 1
B 2
C 6
D 3
E 4
F 5
G 6
H 8
My output:
level grade
A 8
B 8
C 8
D 8
E 8
F 16
G 0
H 8
but its wrong i want to count how many students have grade
1,2,3,4,5,6
but output display something else.