- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add a percentage (%) sign at the end to each value while using MySQL SELECT statement
To add percentage sign at the end, use CONCAT() function. Let us first create a table −
mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentScore int ); Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentName,StudentScore) values('John',65); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(StudentName,StudentScore) values('Chris',98); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable(StudentName,StudentScore) values('Robert',91); Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+-------------+--------------+ | StudentId | StudentName | StudentScore | +-----------+-------------+--------------+ | 1 | John | 65 | | 2 | Chris | 98 | | 3 | Robert | 91 | +-----------+-------------+--------------+ 3 rows in set (0.00 sec)
Following is the query to add a percentage (%) sign to each value at the end while using MySQL SELECT statement −
mysql> select StudentId,StudentName,concat(StudentScore,'%') AS StudentScore from DemoTable;
This will produce the following output −
+-----------+-------------+--------------+ | StudentId | StudentName | StudentScore | +-----------+-------------+--------------+ | 1 | John | 65% | | 2 | Chris | 98% | | 3 | Robert | 91% | +-----------+-------------+--------------+ 3 rows in set (0.00 sec)
- Related Articles
- How to use a select statement while updating in MySQL?
- How to add static value while INSERT INTO with SELECT in a MySQL query?
- Add a character in the end to column values with MySQL SELECT?
- Storing value from a MySQL SELECT statement to a variable?
- Using the value of an alias inside the same MySQL SELECT statement
- Change value from 1 to Y in MySQL Select Statement using CASE?
- How to sort a particular value at the end in MySQL?
- How to select return value from MySQL prepared statement?
- Remove only the percentage sign from values in a MySQL table?
- How to remove percentage sign at last position from every value in R data frame column?
- Change value from 1 to Y in MySQL Select Statement?
- MySQL case statement inside a select statement?
- Select the maximum for each value in a MySQL table?
- How to call a stored procedure using select statement in MySQL?
- How to use MySQL CASE statement while using UPDATE Query?

Advertisements