Buy Now
Sign in

MySQL CASE Function in DB Read Action

shahabpk , December 28 2019, 13:27
S
shahabpk 43
December 28 2019, 13:27 #390504
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 9
December 28 2019, 22:04 #390506
It MIGHT be but I doubt it. Something like
CASE model.field WHEN 0 then 'Morning' END:aliasmodel.alias
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
S
shahabpk 43
December 29 2019, 04:00 #390507
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 9
December 29 2019, 06:33 #390508
(stuff here):model.alias maybe. But again I doubt it will work
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store