?
Solved

MySQL equivalent of Oracle DECODE function?

Posted on 2003-02-20
3
Medium Priority
?
9,770 Views
Last Modified: 2012-06-21
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
Comment
Question by:mickoc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
drittich earned 400 total points
ID: 7989462
SELECT USERNAME, EMAIL, ID_NUMBER, DATE_REGISTERED, LAST_LOGIN, IF(ACTIVE=1,'Yes','No') ACTIVE, IF(ADMIN=1,'Yes','No') ADMIN FROM MEMBERS
0
 
LVL 8

Expert Comment

by:drittich
ID: 8003677
 
0
 

Author Comment

by:mickoc
ID: 8012090
Great, thanks!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question