My field is ENUM for gender and saves βMβ or βFβ, but is there a way to select the field as βMaleβ or βFemaleβ based on the value?
SELECT IF(gender='M','Male', 'Female') AS Gender
You can do things for him:
SELECT CASE enum_field WHEN 'M' THEN 'Male' WHEN 'F' THEN 'Female' END
Yes, you can use the following query to do this.
SELECT (CASE WHEN field = 'M' THEN 'MALE' WHEN field = 'F' THEN 'FEMALE' END) AS sex FROM table;
Use the CASE statement, for example:
CASE
SELECT CASE FieldName WHEN 'M' THEN 'Male' ELSE 'Female' END FROM TableName
Other technique
select replace(replace(column,'M','Male'),'F','Female') from table