当我尝试使用sql INNER JOIN查询从3表中获取数据时出错

时间:2014-08-09 10:46:02

标签: mysql sql

在mysql数据库中,我有3个表

1)tutor_signup_form,
2)tutor_signup_edu_psle和
3)tutor_signup_edu_olevel。

现在我试图从这3个表中获取所有数据。但使用以下sql查询是行不通的。我收到错误消息

Sql Query我正在使用。

$query =  mysql_query("SELECT tutor_signup_form . *, tutor_signup_edu_psle . *, 
  tutor_signup_edu_olevel . * 
FROM tutor_signup_form
  INNER JOIN tutor_signup_edu_psle ON tutor_signup_form.tutor_id =  
  tutor_signup_form.tutor_id   ,    
  INNER JOIN tutor_signup_edu_olevel ON tutor_signup_form.tutor_id = 
  tutor_signup_edu_olevel.tutor_id
WHERE tutor_signup_form.tutor_id = '$tutor_id' ");

错误消息:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in 
D:\software installed\xampp installed\htdocs\tutor\toplevel\edit_tutor.php on line 31

1 个答案:

答案 0 :(得分:0)

删除INNER JOIN语句之间的逗号:

改变这个:

INNER JOIN tutor_signup_edu_psle ON tutor_signup_form.tutor_id =  
tutor_signup_form.tutor_id  ,      
INNER JOIN tutor_signup_edu_olevel ON tutor_signup_form.tutor_id = 
tutor_signup_edu_olevel.tutor_id

到此:

INNER JOIN tutor_signup_edu_psle ON tutor_signup_form.tutor_id =  
tutor_signup_form.tutor_id
INNER JOIN tutor_signup_edu_olevel ON tutor_signup_form.tutor_id = 
tutor_signup_edu_olevel.tutor_id