Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9848
  • Last Modified:

MySQL equivalent of Oracle DECODE function?

Is there some kind of workaround that would make it possible to achieve the equivalent of Oracle's DECODE function in a MySQL query? Or could it be done through some convoluted PHP code?

I'm trying to return all rows from a table 'members', with the following values:
username
email
id_number
date_registered
last_login
active
admin

The columns 'active' and 'admin' hold the value 1 or 0 to show the member's status.
I want to return 'Yes' or 'No' instead, for usability reasons.
0
mickoc
Asked:
mickoc
  • 2
1 Solution
 
drittichCommented:
SELECT USERNAME, EMAIL, ID_NUMBER, DATE_REGISTERED, LAST_LOGIN, IF(ACTIVE=1,'Yes','No') ACTIVE, IF(ADMIN=1,'Yes','No') ADMIN FROM MEMBERS
0
 
drittichCommented:
 
0
 
mickocAuthor Commented:
Great, thanks!
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now