Concatenate a string in an already created field values set with MySQL TEXT data type

MySQLMySQLi Database

For this, use CONCAT(). Let us first create a table −

mysql> create table DemoTable644 (Title text);
Query OK, 0 rows affected (0.81 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable644 values('Introduction');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable644 values('Welcome in course');
Query OK, 1 row affected (0.10 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable644;

This will produce the following output −

+-------------------+
| Title             |
+-------------------+
| Introduction      |
| Welcome in course |
+-------------------+
2 rows in set (0.00 sec)

Here is the query to concatenate string in text data type −

mysql> update DemoTable644 set Title=concat(Title,' To MySQL');
Query OK, 2 rows affected (0.10 sec)
Rows matched: 2 Changed: 2 Warnings: 0

Let us check table records once again −

mysql> select *from DemoTable644;

This will produce the following output −

+----------------------------+
| Title                      |
+----------------------------+
| Introduction To MySQL      |
| Welcome in course To MySQL |
+----------------------------+
2 rows in set (0.00 sec)
raja
Published on 23-Aug-2019 11:04:31
Advertisements