select - How to output enum/string when selecting from a int column in MySQL -


i'm using view of reports data on mysql. in 1 of table, treat particular column enum when selecting data, it's int.

i knew it's possible use inner join accomplish this, i'll keep last option.

is there way build view or select query can sort of cast int enum , have string output instead of int? like

select convert(int_column, enum('a', 'b', 'c')) table; 

i need store column int, changing column enum require many changes @ application level, , needed 1 particular report, should fine. enum have 11 values only.

if casting not possible, can tertiary operator or inline if works in select?

thanks

use elt() function

   select elt(int_column, 'a', 'b', 'c') table; 

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_elt


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -