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 6655891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:34:33+00:00 2026-05-26T01:34:33+00:00

Here is my database schema: user *user_id *username *password *etc quiz_response *response_id *user_id *question_id

  • 0

Here is my database schema:

user
*user_id
*username
*password
*etc

quiz_response
*response_id
*user_id
*question_id
*response
*is_correct
*answer_time

question_choice
*choice_id
*question_id
*is_correct
*choice (VARCHAR)

question
*question_id
*quiz_id
*question (VARCHAR)

quiz
*quiz_id
*title (VARCHAR)

I am building a quiz web-app using PHP and I am having trouble. Currently, I am trying — with no luck — this query and I know where the problem is, I just don’t know how to solve it. Hence, why I am here on S.O.

// Grab the response data from the database to generate the form
    $query = "SELECT qr.response_id AS r_id, qr.question_id, qr.response, q.question, quiz.title " . 
        "FROM quiz_response AS qr " . 
        "INNER JOIN question AS q USING (question_id) " . 
        "INNER JOIN quiz USING (quiz_id) " . 
        "WHERE qr.user_id = '" . $_SESSION['user_id'] . "'";
    $data = mysqli_query($dbc, $query) or die("MySQL error: " . mysqli_error($dbc) . "<hr>\nQuery: $query"); 

At this point I feel my second Inner Join (INNER JOIN quiz USING (quiz_id)) is the problem. When I don’t include this line and remove the quiz.title from the query it works. So, my question is how do I maintain an atomic database schema while still grabbing the quiz title based on the quiz_id from the table ‘question’? Any help would be much appreciated!

  • 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-05-26T01:34:35+00:00Added an answer on May 26, 2026 at 1:34 am

    I believe that the problem is that quiz_id is not in quiz_response. I use the ON keyword. Try:

    // Grab the response data from the database to generate the form
    $query = "SELECT qr.response_id AS r_id, qr.question_id, qr.response, q.question, 
              quiz.title " . 
             "FROM quiz_response AS qr " . 
             "INNER JOIN question AS q ON (q.question_id = qr.question_id) " . 
             "INNER JOIN quiz ON (quiz.quiz_id = q.quiz_id) " . 
             "WHERE qr.user_id = '" . $_SESSION['user_id'] . "'";
    $data = mysqli_query($dbc, $query) or 
             die("MySQL error: " . mysqli_error($dbc) . "<hr>\nQuery: $query");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my current setup: Database Role - MyDbRole Schema - MySchema User -
Rails 2.3.3 Database and Model Schema User (id,name,email) posts (id,subject,message,user_id) How can I display
I have a schema that looks like this User Id INT Username VARCHAR(100) Password
Just getting into SQL stored queries right now... anyway, here's my database schema (simplified
The Media Wiki database Schema, here , has taught me a lot. Cannot-understand: In
Lets imagine I have the same database schema as here: http://www.databaseanswers.org/data_models/driving_school/index.htm If a customer
We have an Oracle database here that's been around for about 10 years. It's
I am trying to map a legacy database here and I'm running into a
I'm using sphinx to list me some items from my database here. It's almost
I have posted a question about multilanguage database design here, [] What are best

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.