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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:08:00+00:00 2026-06-17T08:08:00+00:00

question table ======================== question_id 1 2 3 4 user_answer table ======================== user_id question_id 33

  • 0
question table
========================
question_id
1
2
3
4


user_answer table
========================
user_id  question_id
33       2
44       4
33       1
44       3

This code will return the question id (2 and 1)
what I want is to retrieve the other question id from table question so I want
the result to be (3 and 4)

   $fadi = mysql_query("SELECT * FROM question
         LEFT OUTER JOIN user_answer
           ON user_answer.question_id = question.question_id
              WHERE user_answer.user_id = 33");

   Print "<table border cellpadding=3>";
   while($info = mysql_fetch_array($fadi))
   { Print "<tr>"; 
    Print "<th>question </th> <td>".$info['question_id'] . "</td></tr>";
   }  Print "</table>"; }
  • 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-17T08:08:01+00:00Added an answer on June 17, 2026 at 8:08 am

    Edit: Improved version.

      $fadi = mysql_query("SELECT * FROM question WHERE  question.question_id NOT IN (SELECT user_answer.question_id FROM user_answer WHERE user_answer.user_id = 33)");
    
       Print "<table border cellpadding=3>";
       while($info = mysql_fetch_array($fadi))
       { Print "<tr>"; 
        Print "<th>question </th> <td>".$info['question_id'] . "</td></tr>";
       }  Print "</table>"; }
    

    MySQLi version:

      $link = mysqli_connect($hostname, $username, $password, $database);
      if (!$link){ 
      echo('Unable to connect to database');
      }
      else{
      $fadi = mysqli_query("SELECT * FROM question WHERE  question.question_id NOT IN (SELECT user_answer.question_id FROM user_answer WHERE user_answer.user_id = 33)", $link);
    
       Print "<table border cellpadding=3>";
       while($info = mysqli_fetch_array($fadi,MYSQL_BOTH))
       { Print "<tr>"; 
        Print "<th>question </th> <td>".$info['question_id'] . "</td></tr>";
       }  Print "</table>"; }
    
      }
      mysqli_close($link);
    

    See in action: http://www.sqlfiddle.com/#!2/27b6f/21

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question. My database table is something like this: | ID |
i have a table which looks similar to this <asp:TableRow><asp:TableCell>Question 1</asp:TableCell><asp:TableCell ID =Question1Text></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell
My question is this: Is it possible to output multiple rows when joining from
I hav a php code where it displays buttons from A-Z: <table id=optionAndAnswer class=optionAndAnswer>
here's my question: I have a table TRUST(id INT, trustlevel INT) which contains records
I have a question. I have here 2 tables table 1 : products product_id
I have a hibernate question. My table is of the form: Id, Date --
This is to be an application-agnostic question, but one I'd like to get a
Greetings! This is my first question. I've searched all over the web as well
I had asked a question here on how to get a sql function(max) result

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.