使用CONCAT函数添加到MySQL列中的现有值?
为了理解这个概念,让我们首先创建一个演示表。
mysql> create table addToExistingValueDemo -> ( -> Instructor_Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Instructor_Name varchar(30), -> Instructor_TechnicalSubject text -> );
使用insert命令在表中插入一些记录。查询如下-
mysql> insert into addToExistingValueDemo(Instructor_Name,Instructor_TechnicalSubject) values('John','C,C++');
mysql> insert into addToExistingValueDemo(Instructor_Name,Instructor_TechnicalSubject) values('Carol','Java,Python');
mysql> insert into addToExistingValueDemo(Instructor_Name,Instructor_TechnicalSubject) values('Bob','MySQL,SQL Server');
mysql> insert into addToExistingValueDemo(Instructor_Name,Instructor_TechnicalSubject) values('David','DataStructure');这是使用CONCAT函数添加到MySQL列中现有值的查询
mysql> update addToExistingValueDemo -> set Instructor_TechnicalSubject=concat(Instructor_TechnicalSubject,', Introduction To Algorithm') -> where Instructor_Id=4; Rows matched: 1 Changed: 1 Warnings: 0
让我们再次检查表记录以查看新更改。查询如下-
mysql> select *from addToExistingValueDemo;
以下是输出
+---------------+-----------------+------------------------------------------+ | Instructor_Id | Instructor_Name | Instructor_TechnicalSubject | +---------------+-----------------+------------------------------------------+ | 1 | John | C,C++ | | 2 | Carol | Java,Python | | 3 | Bob | MySQL,SQL Server | | 4 | David | DataStructure, Introduction To Algorithm | +---------------+-----------------+------------------------------------------+ 4 rows in set (0.00 sec)
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下