Jump to content

SQL Translation, Terminology?

ahuckphin
Go to solution Solved by elpiop,
17 minutes ago, bindydad123 said:

image.png.d229a3660f9aac1cf03c64ced1f5644c.png

 

Is it possible that once data is extracted from the database, before it is shown to the user, it is translated to provide the user with more information? For example, 1 = punch, 2 = kick and 3 = step. 

 

Is translation the right terminology? 

 

In my mind, I imagine every line has to be translated. However is it possible that the translation can appear elsewhere else? Is it even possible to perform translations? 

You can use CASE, for example: 

 

SELECT CASE action
WHEN 1 THEN 'punch'
WHEN 2 THEN 'kick'
WHEN 3 THEN 'step'
else 'something else' // if you want to provide a default case, else will return null for other values
END AS action
FROM vaccinations;

 

image.png.d229a3660f9aac1cf03c64ced1f5644c.png

 

Is it possible that once data is extracted from the database, before it is shown to the user, it is translated to provide the user with more information? For example, 1 = punch, 2 = kick and 3 = step. 

 

Is translation the right terminology? 

 

In my mind, I imagine every line has to be translated. However is it possible that the translation can appear elsewhere else? Is it even possible to perform translations? 

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, bindydad123 said:

image.png.d229a3660f9aac1cf03c64ced1f5644c.png

 

Is it possible that once data is extracted from the database, before it is shown to the user, it is translated to provide the user with more information? For example, 1 = punch, 2 = kick and 3 = step. 

 

Is translation the right terminology? 

 

In my mind, I imagine every line has to be translated. However is it possible that the translation can appear elsewhere else? Is it even possible to perform translations? 

You can use CASE, for example: 

 

SELECT CASE action
WHEN 1 THEN 'punch'
WHEN 2 THEN 'kick'
WHEN 3 THEN 'step'
else 'something else' // if you want to provide a default case, else will return null for other values
END AS action
FROM vaccinations;

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, bindydad123 said:

Is translation the right terminology? 

 

I think "mapping" is the correct term in this case.

 

You would typically do this by joining tables, otherwise @elpiop's solution works if you can't add a table for some reason.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×