使用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)
热门推荐
10 恭喜新郎父母简短祝福语
11 小寒健康祝福语大全简短
12 女性生日祝福语简短优美
13 送花简短有内涵祝福语
14 租房明天搬家祝福语简短
15 考试祝福语简短给对象
16 年底老板祝福语简短的
17 猪年元旦祝福语简短创意
18 新年祝同学祝福语简短