Forums

MySQL CASE Function in DB Read Action

shahabpk 28 Dec, 2019
Hi,
I would like to use the MySQL CASE function in a DB read action to change the value of the table field while displaying in web page like
SELECT Name, 
CASE shift_id
    WHEN 0 then 'Morning'
    WHEN 1 then 'Afternoon'
WHEN 2 then 'Night' END AS InternetApproved FROM Table1
Basically what I want is to display human-readable text instead of id while returning the data in a table. Is it possible in DB read action and if yes how the action should be set up?
Thank you
healyhatman 28 Dec, 2019
It MIGHT be but I doubt it. Something like

CASE model.field WHEN 0 then 'Morning' END:aliasmodel.alias
shahabpk 29 Dec, 2019
Thank you healyhatman,
I tried to put your suggestion in Fields to Retrieve but it returned the error
1054 Unknown column 'CASE AttendanceList.duty_type WHEN  0 then 'Morning' END' in 'field list'
healyhatman 29 Dec, 2019
(stuff here):model.alias maybe. But again I doubt it will work
This topic is locked and no more replies can be posted.