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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:45:05+00:00 2026-06-02T22:45:05+00:00

I want to convert an integer to text in a mySQL select query. Here’s

  • 0

I want to convert an integer to text in a mySQL select query. Here’s what a table looks like:

Languages
--------
1,2,3

I want to convert each integer to a language (e.g., 1 => English, 2 => French, etc.)

I’ve been reading up on CONVERT and CAST functions in mySQL, but they mostly seem to focus on converting various data types to integers. And also I couldn’t find anything that dealt with the specific way I’m storing the data (multiple numbers in one field).

How can I convert the integers to text in a mySQL query?

UPDATE

Here’s my mySQL query:

SELECT u.id, ulp.userid, ulp.languages, ll.id, ll.language_detail
FROM users AS u
JOIN user_language_profile AS ulp ON (ulp.userid = u.id)
JOIN language_detail AS ll ON (ulp.languages = ll.id)
  • 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-02T22:45:07+00:00Added an answer on June 2, 2026 at 10:45 pm

    Use either:

    • MySQL’s ELT() funtion:

      SELECT
        ELT(Languages
           , 'English' -- 1
           , 'French'  -- 2
           -- etc.
        )
      FROM   table_name
      
    • A CASE expression:

      SELECT
        CASE Languages
          WHEN 1 THEN 'English'
          WHEN 2 THEN 'French'
          -- etc.
        END
      FROM table_name
      

    Although, if possible I would be tempted to either JOIN with a lookup table (as @Mr.TAMER says) or change the data type of the column to ENUM('English','French',...).


    UPDATE

    From your comments, it now seems that each field contains a set (perhaps even using the SET data type?) of languages and you want to replace the numeric values with strings?

    First, read Bill Karwin’s excellent answer to “Is storing a delimited list in a database column really that bad?”.

    In this case, I suggest you normalise your database a tad: create a new language-entity table wherein each record associates the PK of the entities in the existing table with a single language. Then you can use a SELECT query (joining on that new table) with GROUP_CONCAT aggregation to obtain the desired list of language names.

    Without such normalisation, your only option is to do string-based search & replace (which would not be particularly efficient); for example:

    SELECT CONCAT_WS(',',
      IF(FIND_IN_SET('1', Languages), 'English', NULL),
      IF(FIND_IN_SET('2', Languages), 'French' , NULL),
      -- etc.
    )
    FROM table_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert a hex string to a 32 bit signed integer in
I have text file looks like that: float a[10] = { 7.100000e+000 , 9.100000e+000
I've got a quick question; I want to convert the text in a textfield
When I want to convert between different integer types, it seems the best syntax
I want to convert an integer ( int or long ) a big-endian byte
I want to create a static Hash table to convert strings to integers .
I want to convert characters into integers based on predetermined values, for example: a
I want to convert String to Date in different formats. For example, I am
I want to convert this linear loop into a concurrent one: for(Item item :
I want to convert a binary file into an array of ascii charcters .

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.