lampcms_com — 2010-01-02T20:00:24-05:00 — #1
I know mysql has such function, but I can't find it.
Let's say I have a column of type enum and it stores one of 3 possible values:
'A', 'D', or 'U'
What I want to do is the result of select to return either A or D or NULL instead of U
basically this is an accecc control value -A for allow, D for deny and U for undefined. But I want the undefined to be returned as null
Let's call my column 'access_control'
so how should I write a select access_control from USER_GROUP?
I hope someone knows exactly how to do this.
felgall — 2010-01-02T20:59:35-05:00 — #2
SELECT CASE access_control WHEN 'A' THEN 'Allow' WHEN 'D' THEN 'Deny' ELSE NULL END FROM user_group
lampcms_com — 2010-01-02T21:57:40-05:00 — #3
OK, CASE!. Thank you.
I was going to use REGEX.