Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8711819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:58:42+00:00 2026-06-13T04:58:42+00:00

I have a database containing 3 tables (member, boat, boatType) and in the method

  • 0

I have a database containing 3 tables (member, boat, boatType) and in the method below two of them is affected. What I want is to list all boats that’s registered on a member, but there’s a problem with the code (at least with the SQL, but I suspect that’s not all).

Thanks in advance.

boatHandler.php:

public function GetMembersBoats($memberId) {

    $query = "SELECT b.boatId, b.length, bt.type
                  FROM boat AS b
                      INNER JOIN member AS m
                          ON b.memberId = m.memberId
                              WHERE m.memberId = ?
                      INNER JOIN boatType AS bt
                          ON b.boatTypeId = bt.boatTypeId
                      GROUP BY b.boatId";

    $stmt = $this->m_db->Prepare($query);
    $stmt->bind_param('i', $memberId);

    $boats = $this->m_db->GetBoats($stmt);
}

database.php:

public function GetBoats($stmt) {
    $boats = array(
            0 => array(),
            1 => array(),
            2 => array()
        );

    $stmt->execute();

    $stmt->bind_result($boatId, $length, $type);

    while ($stmt->fetch()) {
        array_push($boats[0], $boatId);
        array_push($boats[1], $length);
        array_push($boats[2], $type);
    }

    $stmt->Close();

    return $boats;
}

Affected tables:

  • boat: boatId, boatTypeId, length, memberId
  • boatType: boatTypeId, type
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:58:44+00:00Added an answer on June 13, 2026 at 4:58 am

    The WHERE clause has to be listed after the table references. You have to move the WHERE m.memberId = ? to the end of the table references after the FROM and JOINs like so:

    SELECT b.boatId, b.length, bt.type
    FROM boat AS b
          INNER JOIN member AS m
              ON b.memberId = m.memberId
    
          INNER JOIN boatType AS bt
              ON b.boatTypeId = bt.boatTypeId
    WHERE m.memberId = ?
    GROUP BY b.boatId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two MySQL database tables: one containing a list of championships and another
I have a database containing two tables: event and session (one event has multiple
I have a database containing two tables - one, states, contains info about each
I have two database tables containing similar data - one is the amount of
I have a small database with tables containing a small amount of data which
I have a java class containing all the columns of a database table as
I have a database containing a list of status updates and time stamp. by
I have three database tables - one containing units, one containing categories of those
I have a small MS Access database containing four tables and are struggeling with
I have a database containing tables with more than 600 million records and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.