-2

I have this queries that JOINS 2 tables and I am planning to add more table but, I'm already having trouble with two 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);

What is the problem with this query? I'm having an error like this

Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in C:\xampp\htdocs\practice1\admin\edit_info_docs.php on line 9 (this is mysqli_stmt_bind_param($stmt, 'i', $_GET['id']);)

Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in C:\xampp\htdocs\practice1\admin\edit_info_docs.php on line 10 (this is mysqli_stmt_execute($stmt);)

Warning: mysqli_stmt_bind_result() expects parameter 1 to be mysqli_stmt, boolean given in C:\xampp\htdocs\practice1\admin\edit_info_docs.php on line 11 (this is 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);)

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
aron pascua
  • 101
  • 2
  • 9

1 Answers1

0

You have a redundant where keyword before the join clause. Remove it and you should be OK:

SELECT * 
FROM   info
JOIN   crew_rank ON info.id = crew_rank.crew_rank_id 
WHERE  info.id = ?
Mureinik
  • 297,002
  • 52
  • 306
  • 350