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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:05:43+00:00 2026-05-26T14:05:43+00:00

I need to export data from an existing TABLE. Till recently I used –

  • 0

I need to export data from an existing TABLE. Till recently I used –

SELECT item_ID, item_Info, ...moreFields... FROM tableName WHERE myCondition=0

Now, they changed the TABLE structure, and added new field “item_Info2”

When they fill in the TABLE:

  • if “item_Type” is 1 or 2 or 3 or 4, then “item_Info” is relevant
  • if “item_Type” is 5, then “item_Info” is empty, and I need “item_Info2” as my query result, instead of “item_Info”

What is the corresponding SELECT command?

[similiar question: mysql select any one field out of two with respect to the value of a third field

but from this example I cannot see the syntax for selecting moreFields ]

Thanks,

Atara.

  • 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-26T14:05:44+00:00Added an answer on May 26, 2026 at 2:05 pm

    You can treat the CASE statement as any other column name, separate it from the other columns with a comma, etc. What happens in the CASE should be considered a single column name, in your case you need commas before and after it.

    SELECT item_ID, CASE WHEN item_Type = 5 THEN item_info ELSE item_info2 END, field_name, another_field_name ...moreFields... FROM tableName WHERE myCondition=0
    

    you could also use an alias to be easier to get the result from the query:

    SELECT item_ID, CASE WHEN item_Type = 5 THEN item_info ELSE item_info2 END AS 'item_info', field_name, another_field_name ...moreFields... FROM tableName WHERE myCondition=0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to export data from a table in database A, then import it
I need to export data to a file from a huge table with only
I want to export data from a table to a specifically formatted XML file.
I need to export the data from 36 SQL tables containing 24GB of data
I need to export the resulting data from a query in PostgreSQL to Excel/CSV.
I need to export data from php to Excel, and be able to format
I need to export some data from PostgreSQL to Excel (quick customer wish), and
Please help. I need a CakePHP 1.2 code that needs to export data from
I need to export big amount of data from database. Here is classes that
I need data from 3 different tables: Catergory table Scoretable 1 Scoretable 2 What

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.