如果where等于数组索引,则在php mysql中选择where
嘿,伙计们,我正试图用php查询一些东西,但WHERE是数组中的索引,这就是我所做的如果where等于数组索引,则在php mysql中选择where,php,mysql,arrays,Php,Mysql,Arrays,嘿,伙计们,我正试图用php查询一些东西,但WHERE是数组中的索引,这就是我所做的 $data=array(); while ($row = mysql_fetch_array($result)) { $item = array( 's
$data=array();
while ($row = mysql_fetch_array($result))
{
$item = array(
'sec_id'=>$row['section_id'],
'sec_name'=>$row['section_name'],
'sec_dept'=>$row['section_department'],
'sec_lvl'=>$row['section_level'],
'advisory_id'=>$row['advisory_id'],
'first_name'=>$row['f_firstname'],
'last_name'=>$row['f_lastname'],
'middle_name'=>$row['f_middlename'],
'advisor_id'=>$row['faculty_id'],
);
$get_subjects = "SELECT subject_name
FROM subjects
WHERE level = '".$row['section_level']."' ";
$result_get_subjects =mysql_query($get_subjects)or die(mysql_error());
$subjects_count = mysql_num_rows($result_get_subjects);
$check_archive_subjects = " SELECT b.subject_name
FROM registrar_grade_archive a
LEFT JOIN subjects b ON(a.subject_id=b.subject_id)
LEFT JOIN section c ON(a.section_id = c.section_id)
WHERE a.advisor_faculty_id ='".$row['faculty_id']."'
WHERE a.section_id ='".$row['section_id']."'
GROUP BY b.subject_name ASC
" ;
$query_checking =mysql_query($check_archive_subjects)or die(mysql_error());
$subjects_count_sent = mysql_num_rows($query_checking);
但不幸的是,我在$check_archive_主题中遇到了一个错误,它说:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE a.section_id ='24'
在mysql的where子句中是否有其他方法放置数组索引。我知道mysql已经被弃用了,我会在我完成这个项目后切换到mysqli,所以请原谅我。提前感谢多个
,其中
条件应使用布尔关键字和
或或
进行连接。您不会发出多个WHERE
子句
另外,请阅读有关MySQL扩展的文章-多个
,其中应使用布尔关键字和或或连接条件。您不会发出多个WHERE
子句
另外,请阅读有关MySQL扩展的文章-尝试下面的查询
SELECT b.subject_name
FROM registrar_grade_archive a
LEFT JOIN subjects b ON(a.subject_id=b.subject_id)
LEFT JOIN section c ON(a.section_id = c.section_id)
WHERE a.advisor_faculty_id ='".$row['faculty_id']."' AND a.section_id ='".$row['section_id']."'
GROUP BY b.subject_name ASC
解释
在MySQL中不接受使用上述多个WHERE
子句。根据您的要求,尝试使用和或使用或替换第二个,其中
。我已经使用了和尝试下面的查询
SELECT b.subject_name
FROM registrar_grade_archive a
LEFT JOIN subjects b ON(a.subject_id=b.subject_id)
LEFT JOIN section c ON(a.section_id = c.section_id)
WHERE a.advisor_faculty_id ='".$row['faculty_id']."' AND a.section_id ='".$row['section_id']."'
GROUP BY b.subject_name ASC
解释
在MySQL中不接受使用上述多个WHERE
子句。根据您的要求,尝试使用和或使用或替换第二个,其中
。我用过和哦!!。。我真傻。。我以为是阵列。谢谢顺便说一句,我已经读过了。我仍然在使用mysql bcuz,这是我们的教授对我们的想法,最近我发现当我们已经开始这个项目时,它已经被弃用了。哦!!。。我真傻。。我以为是阵列。谢谢顺便说一句,我已经读过了。我仍然在使用mysql bcuz这是我们的教授对我们的想法,最近我发现当我们已经开始这个项目时,它已经被弃用了。