Answer the question
In order to leave comments, you need to log in
MySQL VIEW: Display ID as text ("decode")
Hi all!
Can you tell me how in MySQL you can map values to other values?
For example, there is a table
event_id, event_type
1, 2
2, 1
3, 3
4, 5
5, 2
...
I want to display as
event_id, event_description
1, buy
2, sell
3, view
4, undefined
5, buy
...
event_type pairs => event_description, of course, are known
. Is it possible to do this with VIEW without using an additional lookup table?
Answer the question
In order to leave comments, you need to log in
select id,
case report.type
when 'P' then amount
when 'N' then -amount
end as amount
from
`report`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question