$r1 = mysqli_query($con,"SELECT course_id,status FROM attendance WHERE stud_id = '$stud_id'");
$r2 = mysqli_query($con,"SELECT course_name,status FROM **$r1** NATURAL JOIN course WHERE stud_id = '$stud_id'");
答案 0 :(得分:0)
您可能必须使用subquery。
$r2 = mysqli_query($con,"SELECT course_name,status FROM
(SELECT course_id,status FROM attendance WHERE stud_id = '$stud_id')
NATURAL JOIN course WHERE stud_id = '$stud_id'");
答案 1 :(得分:0)
首先,永远不要使用没有正确转义的变量(mysqli::real-escape-string)
你可以加入两个这样的表:
$r2 = mysqli_query(
$con,
"SELECT c.course_name, a.status FROM attendance a
INNER JOIN course c ON c.stud_id = a.stud_id
WHERE stud_id = '$stud_id'"
);