Nagu
Nagu

Reputation: 5114

query result alias

Hi I've a query like this

select * from emplyees

result is

name    dept      status
emp1    Admin      y
emp2    admin      n

I'm going to bind it to gridview like mygridview.datasource = ds;

now here i want to display approve instead of y and disapprove instead of n

how can i write a query ?

thank you

Upvotes: 0

Views: 116

Answers (2)

Beatles1692
Beatles1692

Reputation: 5320

You can use DataGridView (Windows Forms) cell formatting mechanism to format value of a cell.

Here's an example.

Upvotes: 0

Pete OHanlon
Pete OHanlon

Reputation: 9146

You don't state what database you are using. If you are using SQL Server, then you could write this as:

SELECT name, dept, CASE WHEN STATUS = 'Y' THEN 'Approve' ELSE 'Disapprove' END AS STATUS
FROM EMPLOYEES

Upvotes: 7

Related Questions