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

The Archive Base Latest Questions

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

i have a questions database of the shape ID , Question , Answer1 ,

  • 0

i have a questions database of the shape

ID , Question , Answer1 , Answer2 , Answer3 , Answer4 , True

where “True” is the index of the correct answer:

True = 0 --> Answer1
....
True = 3 --> Answer4

i need to select only the question and the correct answer, this is what i got so far:

SELECT Question , 'Answer' || (True+1) From Questions

but it returns the question and ‘answer1’ or ‘answer2’ … ie: the name of the column i need not it’s value

  • 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-17T16:08:40+00:00Added an answer on June 17, 2026 at 4:08 pm

    you can use CASE in MySQL.

    SELECT  Question,
            CASE True
                WHEN 0 THEN Answer1
                WHEN 1 THEN Answer2
                WHEN 2 THEN Answer3
                WHEN 3 THEN Answer4
            END AS Answer
    FROM    tableName
    

    OR

    SELECT  Question,
            CASE 
                WHEN TRUE = 0 THEN Answer1
                WHEN TRUE = 1 THEN Answer2
                WHEN TRUE = 2 THEN Answer3
                WHEN TRUE = 3 THEN Answer4
            END AS Answer
    FROM    tableName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataset that returns questions and answers from the database, each answer
My database contains both questions and answers. The questions have an ID (intQAID) and
basically i have a database, which contains a random amount of questions i have
I have a MS access database. In that, one table consists of questions and
I have a question regarding my database design and its implementation that i am
I have posted a question about multilanguage database design here, [] What are best
I have a question. My database table is something like this: | ID |
I have this question in which I have a SQL Server Compact Edition database
i have read many posts but can not find my answer.my question is a
I have inherited a very disorganized VSS database and I need to clean it

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.