Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Add a character in the end to column values with MySQL SELECT?
For this, you need to perform concatenation using CONCAT().
Let us first create a table −
mysql> create table DemoTable766 (Name varchar(100)); Query OK, 0 rows affected (0.65 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable766 values('John');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable766 values('Sam');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable766 values('Carol');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable766 values('David');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable766 values('Bob');
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable766;
This will produce the following output -
+-------+ | Name | +-------+ | John | | Sam | | Carol | | David | | Bob | +-------+ 5 rows in set (0.00 sec)
Following is the query to add a character in the end to column values −
mysql> select concat(Name,' S') from DemoTable766;
This will produce the following output -
+-------------------+ | concat(Name,' S') | +-------------------+ | John S | | Sam S | | Carol S | | David S | | Bob S | +-------------------+ 5 rows in set (0.00 sec)
Advertisements
