I have MySQL and the query is:
select name,re_type from myTable
I want to replace all values of type:
1 = student
2 = teacher
So the result should be:
name re_type
---------------
Ron Student
Mac Teacher
Not like:
name re_type
---------------
Ron 1
Mac 2
Is it possible to make a query like that so I get the desired result in MySQL ?
You can use a CASE statement
SELECT name, CASE WHEN re_type = 1 THEN 'Student' WHEN re_type = 2 THEN 'Teacher' ELSE 'Donno' END AS re_type_text
FROM myTable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With