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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:15:00+00:00 2026-05-29T05:15:00+00:00

In my database, I’m storing a field called type as tinyInt, since I don’t

  • 0

In my database, I’m storing a field called “type” as tinyInt, since I don’t have that many types I decided not to create a table for storing the corresponding names of all these types.

When I query my table I want the types to be replaced by their corresponding names which I’m storing in php arrays. I wonder if there is a way to do this replacement inside the sql statement itself instead of looping through the results and do replacement on the returned result row.

Does something like this even exists:

select *, map(type, {1=>'abc', 2 => 'xyz'}) from orders
  • 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-29T05:15:01+00:00Added an answer on May 29, 2026 at 5:15 am

    The only way (I’m fairly sure) to do this is using a CASE .. WHEN ... construct:

    SELECT *, CASE type WHEN 1 THEN 'abc' WHEN 2 THEN 'xyz' END as stringType
    FROM orders
    

    You can also use the ELSE clause to specify a default, e.g. CASE type WHEN 1 THEN 'abc' WHEN 2 THEN 'xyz' ELSE 'unknown' END.

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

Sidebar

Related Questions

Many database systems don't allow comments or descriptions of tables and fields, so how
database/SQL novice here. I have a table with a column called, for example, EmployeeID.
My database contains records that have: 1) First line delimited with double \n\n and
The database has a ton of entries that were not escaped because they were
My database contains 3 tables: User and Service entities have many-to-many relationship and are
Database server is Microsoft SQL Server, but I don't have Administrator access to it.
Database resources, that can be accessed from webpage that I'm currently working on, have
Database: DB2 v9.5 on AIX Scenario: I have 2 instances- db2inst1 and db2inst2. I
Database has tables Photos and PhotoAlbums. I need a query that will select all
A database application that I'm currently working on, stores all sorts of settings in

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.