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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:39:43+00:00 2026-05-25T16:39:43+00:00

I have data like this id | bookDate | regisDate | payDate | status

  • 0

I have data like this

id | bookDate   | regisDate  | payDate    | status  
1  | 2001-12-31 | 2002-12-31 | 2003-12-31 | 1  
2  | 2001-12-31 | 2002-12-31 | 2003-12-31 | 2  
3  | 2001-12-31 | 2002-12-31 | 2003-12-31 | 3  

and i want the result is like this

id | date | status 
x  | x    | x

notice date field is reduced from 3 into 1 field. and the conditional is like this. if the status is 1 then take date from bookDate, if 2 take from regisDate, if 3 take from payDate

example for data with id 1, then the result of query will be like this

id | date       | status 
1  | 2001-12-31 | 1

it is possible do that in MySQL query?

  • 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-25T16:39:44+00:00Added an answer on May 25, 2026 at 4:39 pm

    You have case statements in MySQL.

    SELECT id,
     CASE status
      WHEN 1 THEN bookDate
      WHEN 2 THEN regisDate
      WHEN 3 THEN payDate
     END
     AS date,
     status
     FROM table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have some data like this: number_stream = [0,0,0,7,8,0,0,2,5,6,10,11,10,13,5,0,1,0,...] I want to process
I have data like this alt text http://img252.imageshack.us/img252/8518/data.png I want to update minP, maxP
I have data like this (col2 is of type Date) | col1 | col2
If I have data like this DF <- data.frame( date = seq(Sys.Date()-1000, len=1000, by=1
I have JSON data like this: [{id:3,name:jason},{id:4,name:karen}] I want to build a table view
If I have data like this: Key Name 1 Dan 2 Tom 3 Jon
Say I have data like this: <option value=abc >Test - 123</option> <option value=def >Test
I have a table like this: Application,Program,UsedObject It can have data like this: A,P1,ZZ
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have some data like this : 1 TC1 PASS 2 TC2 FAIL 3

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.