0

I have a query that will output something like this:

1 | 1 | Project A
2 | 0 | Project B

And I would like to obtain this:

1 | Yes | Project A
2 | No  | Project B

So, 1 must be converted to Yes and 0 to No. How can I do that directly in the query?

SELECT 
    project.id,
    project.status,
    project.name
FROM
    project
anvd
  • 3,997
  • 19
  • 65
  • 126

1 Answers1

1

Use case:

select 
    publication_id,
    case when publication_status then 'Yes' else 'No' end status,
    project_name
from project

In MySQL, 1 evaluates as true when used in a conditional expression.

NB: there is no publication table involved in the query, so I can only assume that publication.id is actually publication_id (same goes for publication.status).

GMB
  • 216,147
  • 25
  • 84
  • 135