mysql insert union_在MySQL中使用INSERT INTO SELECT和UNION执行多次插入
要执行多次插入,语法如下:insert into yourTableName(yourColumnName1,yourColumnName2,yourColumnName3,..N)
select yourValue1 as yourColumnName1,yourValue2 as yourColumnName2,yourValue3 as yourColumnName3,......N
union
select yourValue1 as yourColumnName1,yourValue2 as yourColumnName2,yourValue3 as yourColumnName3,......N
.
.
N
要了解上述语法,让我们创建一个表-create table DemoTable1936
(
StudentId int,
StudentName varchar(20),
StudentCountryName varchar(20)
);
使用插入命令在表中插入一些记录-insert into DemoTable1936(StudentId,StudentName,StudentCountryName)
select 1001 as StudentId,'Chris' as StudentName,'US' as StudentCountryName
union
select 1002 as StudentId,'Robert' as StudentName,'UK' as StudentCountryName
union
select 1003 as StudentId,'David' as StudentName,'AUS' as StudentCountryName;
Records: 3 Duplicates: 0 Warnings: 0
使用select语句显示表中的所有记录-select * from DemoTable1936;
这将产生以下输出-+-----------+-------------+--------------------+
| StudentId | StudentName | StudentCountryName |
+-----------+-------------+--------------------+
| 1001 | Chris | US |
| 1002 | Robert | UK |
| 1003 | David | AUS |
+-----------+-------------+--------------------+
3 rows in set (0.00 sec)
mysql insert union_在MySQL中使用INSERT INTO SELECT和UNION执行多次插入相关推荐
- MySQL数据库应用———修改表中内容INSERT/UPDATE/DELETE
插入.更新.删除表中数据 1.表格中插入数据内容 insert into 语法规则为: INSERT INTO 表名 (字段名) VALUES (内容); 举例: insert into tb_nam ...
- ibatis insert mysql_让iBatis中的insert返回主键
让iBatis中的insert返回主键 [ibatis insert 返回 自增主键] parameterClass="RemarkInfo"> insert into SG ...
- oracle insert into insert,总结下Oracle 中的Insert用法
1.标准Insert --单表单行插入 语法: INSERT INTO table [(column1,column2,...)] VALUE (value1,value2,...) 例子: inse ...
- c语言insert作用,C++string中的insert()插入函数详解
下面通过代码给大家介绍c++ string insert() 函数,具体内容如下: basic_string& insert (size_type pos, const basic_stri ...
- mysql insert if exists_mysql数据库中的insert if not exists
当记录不存在时插入,即insert if not exists.mysql中,插入(insert)一条记录很简单. 但在一些特殊应用中,插入记录前,需要检查这条记录是否已存在,只有当记录不存在时才执行 ...
- oracle的insert写法,oracle中的insert语句
关键字: ORACLE insert into table oracle中的insert语句 在oracle中使用DML语言的insert语句来向表格中插入数据,先介绍每次只能插入一条数据的语法 IN ...
- centos下mysql 命令_CentOS下mysql数据库常用命令总结
### 1.更改root密码 `mysqladmin -uroot password 'yourpassword'` ### 2.远程登陆mysql服务器 `mysql -uroot -p -h192 ...
- mysql insert 几分钟_我们可以在MySQL中应用INSERT语句时向VARCHAR日期时间记录添加分钟吗?...
是的,我们可以在将值插入表中时增加分钟数.让我们首先创建一个表.在这里,我们有一列包含VARCHAR记录,其中mysql> create table DemoTable2026 -> ( ...
- mysql+inser+select_解析MySQL中INSERT INTO SELECT的使用
1. 语法介绍 有三张表a.b.c,现在需要从表b和表c中分别查几个字段的值插入到表a中对应的字段.对于这种情况,可以使用如下的语句来实现: INSERT INTO db1_name (field1, ...
最新文章
- 你想要的生物信息知识全在这——生信宝典文章目录
- jenkins 配置slave
- 最短路径·三:SPFA算法 HihoCoder - 1093 (spfa无向图)
- APM - 零侵入监控Http服务
- 团队项目个人进展——Day08
- 机器学习经典必读书,李航《统计学习方法》出视频课了!
- ×××S 2012 交互式报表 -- 同步交互式排序
- 前端学习(2848):鼠标点击事件
- EAS 表格、查询方案存储表
- 自学python好找工作么-学完Python好找工作吗?为什么有人学完找不到工作?
- 阿里云 centos7 tomcat 启动巨慢的解决方法(几分钟)
- 高清人脸数据集汇总 (主要用于人脸生成、分割任务)
- 美团 O2O 供应链系统架构设计解析
- 论文笔记:Exploiting Cloze Questions for Few Shot Text Classification and Natural Language Inference
- a += 1、a = a + 1、a++区别
- ChromeFK插件推荐系列二十三:在线文字转语音/语音朗读插件推荐
- K8S集群扩容多master大概思路步骤
- insert 插入数据
- java支付宝提现功能,单笔转账到支付宝账户(公钥证书方式)
- 解决SSH连接不上的问题