Amayak
Amayak

Reputation: 39

How to add "%" symbol to the value in mysql?

how can I add "%" to the value in the column?

I have Orders like

|Orders|
|------|
|  32  |
|------|
|  33  |

And I need

|Orders|
|------|
| 32%  |
|------|
| 33%  |
|------|

Upvotes: 1

Views: 409

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726509

Formatting a number as percentage is a display issue, not a data issue. Moreover, it is locale-specific. For instance, in France there needs to be a space between the number and the '%' sign, while in Germany and United States there is no space.

Don't add % to the value in the database table. Instead, store the number of percents, as an int, or a fraction, as a decimal with the needed precision.

This way you would retain an ability to manipulate percentages as numbers within the database.

Upvotes: 1

Related Questions