user2595861
user2595861

Reputation: 83

How to change a column name and display with special characters?

I am trying to display one column name with '%' i.e the "ip_utilization" column as "usage%" column here. But i am not able to, can anyone suggest a solution please. I am sharing the query.

select ip_name, concat (first_name, ' ' ,last_name) as Contact, ip_utilization as usage_% from database_name;

Upvotes: 1

Views: 608

Answers (4)

Pekka
Pekka

Reputation: 449385

Just give it a different column name? Like usage_percentage.

It may be possible to have the percent sign using backticks, but to what end? What point is there in jumping through hoops to somehow have a weird special character in a name that usually won't be displayed in an application anyway?*

(Unless it's really a public-facing app and you can't change the name on application level at all. But that should be the rare exception.)

Upvotes: 1

hd1
hd1

Reputation: 34657

Enclose usage_% in `` as below:

select ip_name, concat (first_name, ' ' ,last_name) as Contact, ip_utilization as `usage_%` from database_name;

If you have further problems, leave a comment.

Upvotes: 0

Joe Taras
Joe Taras

Reputation: 15379

Quote usage%. But I advice to change the name, because % is keyword used for like command.

select ip_name, concat (first_name, ' ' ,last_name) as Contact,
ip_utilization as 'usage_%' from database_name;

Upvotes: 0

suff trek
suff trek

Reputation: 39767

You should be able to use backticks

select ip_name, concat (first_name, ' ' ,last_name) as Contact, ip_utilization as `usage_%` from database_name;

Upvotes: 0

Related Questions