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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:54:14+00:00 2026-05-29T16:54:14+00:00

Consider the following query: SELECT operation, […] FROM tableName The operation field will retrieve

  • 0

Consider the following query:

SELECT operation, [...] FROM tableName

The operation field will retrieve an integer from 1 to 4. What I would like to do is assign a string value to a variable in the SQL query, based on the integer value of operation.

If it were up to me, I would have a corresponding table that contained the name of each operation, in which case a JOIN would pick up the operation string. Unfortunately, I do not control the database.

I don’t know if this is even something SQL can do, and I could certainly iterate over the returned data using PHP to perform this task instead, but it makes sense to do it all in one hit if possible.

  • 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-29T16:54:15+00:00Added an answer on May 29, 2026 at 4:54 pm

    Try something kile this:

    SELECT 
      CASE 
         operation
      WHEN 1 THEN 'OP1'
      WHEN 2 THEN 'OP2'
      WHEN 3 THEN 'OP3'
      WHEN 4 THEN 'OP4'
      ELSE
         'Unknown OP'
      END OperationName
      , 
    [...] FROM tableName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following queries. select * from contact where firstname like '%some%' select *
Please consider the following: $query = SELECT legIDs FROM trip; $result = mysql_query($query) or
Consider the following SQL Server 2005/2008 query: Select [UID], [DESC] From SomeTable Order By
I have the following query in SQLite: SELECT * FROM t1 ORDER BY t1.field
Consider the following JPQL query: SELECT foo FROM Foo foo INNER JOIN FETCH foo.bar
Consider the following WSH snippet: var query = GetObject(winmgmts:).ExecQuery(SELECT Name FROM Win32_Printer, WQL, 0);
Consider the following query: SELECT domain, done FROM tasks WHERE 1 GROUP BY domain
Please consider following sample query SELECT * FROM subscriber WHERE subscription_date>DATE(NOW()-INTERVAL 10 DAY) My
Consider the following query: INSERT INTO statement_line_items SELECT count(*)::integer as clicks, sum(amount_cents)::integer as amount_cents,
Consider the following 3 standard statements $queryString = SOME SQL SELECT QUERY; $queryResult =

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.