2016-11-10 67 views
-1

我想的谁已经申请了特定类别是活跃的人名单,但我不能得到正确的结果MySQL查询返回我的Web应用程序不正确的结果

下面是我查询我试图

$Query = mysql_query("select s_p_I.name,p_s.Seatno,t_s 
         from student_pers_info s_p_I, pat_students p_s,test_score t_s,current_category c_c,candidate_selected_category c_s_c 
         where (s_p_I.pat_code=p_s.pat_code) 
          && (s_p_i.pat_code =t_s.pat_code) 
          && (c_c.category_code =c_s_c.category_code) 
          && (c_c.active = c_s_c.active) = 1") 

问题发生在最后一个条件带来的所有记录谁都是在candidate_selected_category表和具有活性值1

+1

选择请不要在不同的表'使用'mysql_'函数,因为它们都是[弃用和安全风险](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – roberto06

+0

请学习使用代码格式。 – CGritton

+1

请参阅http://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-查询如何改善您的问题的指导。 – Shadow

回答

0

好像有缺失SOMET在此行的最后欣:

select s_p_I.name,p_s.Seatno,t_s 

(应该有t_s后的视场名称)

而在第二行,你应该使用JOIN的为你从