如何在mysqli中加入多个表?

时间:2016-09-13 07:17:14

标签: php mysql mysqli

我有queries加入2个表,我打算添加更多表格但是,我已经遇到了两个问题tables

$query = "SELECT * FROM info WHERE JOIN crew_rank ON info.id = crew_rank.crew_rank_id WHERE info.id = ?";
  $stmt = mysqli_prepare($conn, $query);
  mysqli_stmt_bind_param($stmt, 'i', $_GET['id']);
  mysqli_stmt_execute($stmt);
  mysqli_stmt_bind_result($stmt, $id, $full_name, $phone_number, $crew_rank,$date_of_birth,$age,$telephone_number,$vessel,$place_of_birth,$religion,$joining_date);

你能帮助我们这个query有什么问题吗?我有这样的错误

  

警告:mysqli_stmt_bind_param()要求参数1为mysqli_stmt,第9行的C:\ xampp \ htdocs \ practice1 \ admin \ edit_info_docs.php中给出布尔值   (这是mysqli_stmt_bind_param($stmt, 'i', $_GET['id']);

     

警告:mysqli_stmt_execute()要求参数1为mysqli_stmt,第10行的C:\ xampp \ htdocs \ practice1 \ admin \ edit_info_docs.php中给出布尔值   (这是mysqli_stmt_execute($stmt);

     

警告:mysqli_stmt_bind_result()要求参数1为mysqli_stmt,第11行的C:\ xampp \ htdocs \ practice1 \ admin \ edit_info_docs.php中给出布尔值   (这是mysqli_stmt_bind_result($stmt, $id, $full_name, $phone_number, $crew_rank,$date_of_birth,$age,$telephone_number,$vessel,$place_of_birth,$religion,$joining_date);

提前谢谢

1 个答案:

答案 0 :(得分:0)

where子句之前有一个冗余的join关键字。删除它,你应该没问题:

SELECT * 
FROM   info
JOIN   crew_rank ON info.id = crew_rank.crew_rank_id 
WHERE  info.id = ?