首先,我知道MySQL是一種折舊語言,但我的主管堅持使用它。將多個表中的數據插入到一個單獨的表中
我在我的數據庫中有三個表。他們是:「學生」,「導師」,「匹配」。當我找到運行下面的查詢($ query2)時,我正在檢查確保該查詢中的所有條件都完全匹配。
當完美匹配我想插入以下到匹配表:
"insert into match (tutor_id, student_id, school_id) values ('$tutor_id','$student_id','$school_id')";
的「匹配」表中包含列:
match_id(auto incremented), tutor_id, student_id, school_id
任何幫助將不勝感激。
if(mysql_query($query2)){
$check_availability = "select *
from tutors, students
where tutor_availability = '$student_availability'
AND (tutor_subject_1 = '$student_subject_1'
OR tutor_subject_1 = '$student_subject_2'
OR tutor_subject_2 = '$student_subject_2'
OR tutor_subject_2 = '$student_subject_1')";
$run_5 = mysql_query($check_availability);
if(mysql_num_rows($run_5)>0) {
echo "<script>alert('we have a match')</script>";
my_sql_query($query3) = "insert into match (tutor_id, student_id, school_id) values ('$tutor_id','$student_id','$school_id')";
mysql_query($query3);
} else{
echo "<script>alert('no match found')</script>";
}
}
MySQL是絕不棄用的語言,PHP mysql_ *功能 –
那麼什麼是您的問題...? – user1844933
這些值不會進入「匹配」表 – bano590