2016-11-10 70 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的爲你從