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

  • Home
  • SEARCH
  • 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 8708845
In Process

The Archive Base Latest Questions

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

I have a query below where a user will type in a term from

  • 0

I have a query below where a user will type in a term from a question and it will output questions which contains that term and with it, it will display associated with the question it’s answer, its option type, it’s reply type etc.

Below is the query:

SELECT DISTINCT q.QuestionContent, o.OptionType, q.NoofAnswers, 
                GROUP_CONCAT(DISTINCT Answer SEPARATOR '') AS Answer, 
                r.ReplyType, q.QuestionMarks, q.SessionId   
FROM Answer an    
JOIN Question q 
ON q.QuestionId = an.QuestionId 
AND an.SessionId = q.SessionId   
JOIN Reply r 
ON q.ReplyId = r.ReplyId    
JOIN Option_Table o 
ON q.OptionId = o.OptionId 
WHERE ".implode(" AND ", array_fill(0, $numTerms, "q.QuestionContent LIKE ?"))."
GROUP BY an.SessionId, an.QuestionId

Now I realise that by using CRON, every year it will delete previous Exams (SessionId) meaning that these questions will not appear for the user to search in the user.

So what I wanted to do was set up a table where it stores all previous questions, the table is below:

Previous_Question Table:

PreviousId (auto) PreviousContent
1                 What is 2+2? 
2                 What is 4+4 and 3+3?
3                 What is square root of 144?

So I want to use the Previous_Question Table to be able to search for previous questions. so I need to change query above The biggest problem though is that this table does not link to any other table, meaning that how am I going to be able to retrieve it’s correct Answer, Reply Type, Option Type etc? This is my problem.

Any help?

EDIT:

Below are the other tables:

Question Table

SessionId QuestionId  QuestionContent             NoofAnswers ReplyId QuestionMarks OptionId
AAA       1           What is 2+2?                  1          1          5         2
AAA       2           What is 4+4 and 3+3?          1          2          5         3
ABC       3           What is square root of 144?   1          1          7         5

Answer Table:

AnswerId(auto) SessionId QuestionId  Answer
1              AAA       1           B
2              AAA       2           A
3              AAA       3           D
4              ABC       1           A

Reply Table:

ReplyId ReplyType
1       Single
2       Multiple

Option Table:

OptionId  OptionType
1         A-C
2         A-D
3         A-E
4         A-F
5         A-G

Now lets say that SessionId “AAA” get deleted, that means all of the corresponding rows which contains “AAA” for SessionId in “Question” table will be deleted. But just realised that so would the corresponding answers.

I need to help on somehow set up something where it will store previous questions and its details (Answers, Reply Type, Option Type) etc so that even though questions and answers are deleted because their session has been deleted, that the teacher can some how pick out those questions which are stored somewhere so the teacher can still be selecting those questions and their relevant answers, options type, reply type etc.

  • 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:13:53+00:00Added an answer on June 13, 2026 at 4:13 am

    Quick shot… you can either change the structure of your session table and add a bool field, let’s say “active”. Then, run a query over that table, and set active to TRUE.
    And, instead of delete the session, just change the value to inactive. So next time when you need to, just check if active=TRUE.

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

Sidebar

Related Questions

I have an SQL query (below) that essentially takes a student from tbStudents, and
postgreSQL question...I have an update query below which updates a column with the results
Summary So I have 3 tables, which I have screenshots below. Every user will
I have a query below that I use to retrieve the records not updated
I have the query below that when run it says that 325 rows were
The query below returns rows that have both loginid and ip2 in the bumps
I have the below query in a postgresql database SELECT * FROM accounts where
I have a query like below... SELECT contents.id, contents.title, contents.createdBy, (SELECT userGroup FROM suser_profile
Scenario: I have multiple text boxes in which a user will enter data into
So I have a query, as shown below, which runs on a parameter. I

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.