我不明白为什么这个语句不起作用
$sql2 = mysql_query("
SELECT myChurches.id AS id, myChurches.church_name AS church_name
FROM myChurches
INNER JOIN church_staff
ON church_staff.church_id=myChurches.id
WHERE church_staff.mem_id='$logOptions_id'
ORDER BY myChurches.church_name
ASC
")
if(mysql_num_rows($sql2) > 0){
while($row2 = mysql_fetch_array($sql)){
$church_id = $row2['id'];
$church_name = $row2['church_name'];
$options .= '<option value="'.$church_id.'">'.$church_name.'</option>';
}
}
基本上,我需要从一张桌子上找到作为教堂工作人员的人,并希望从“myChurches”表格中获取该教堂的“名称”。希望这是有道理的。提前致谢
编辑:
表 1 具有唯一的 id 和 Church_name
表 2 具有唯一 id、church_id 和 mem_id