Changing value of a field in a select

3

Query:

select id_cliente,nm_cliente,tp_sexo from tb_clientes;

In my bank, sex is registered as int would like when I make a select displayed Male or Female instead of 1 or 2 , how do I do it?

    
asked by anonymous 22.11.2015 / 01:40

1 answer

2

Use case ... when :

select nm_cliente, case tp_sexo
when 1 then 'Masculino'
when 2 then 'feminino' end as strSexo
from  tb_clientes

See an example working in SQLFIDDLE

References:

link

link

link

    
22.11.2015 / 02:01