mysql之insert
前言
简单记录insert命令的使用
用法
insert into
INSERT INTO student(NAME, salary, created_at) VALUES(‘xing‘, 900, CURDATE());
insert into values
- 需要添加所有列的值
INSERT INTO student VALUES(1, ‘xing‘, 900, CURDATE());
insert into select from
- 通常用于处理数据后插入已存在的表
- insert into中的列数量必须和select的保持一致,否则会报错的
INSERT INTO GoodsUrl ( id, url, created_at, updated_at ) SELECT Goods.id AS id, CONCAT_WS( ‘/‘, Domains.`name`, Goods.sitedir ) AS url, Goods.created_at AS created_at, Goods.updated_at AS updated_at FROM Goods, Domains WHERE Goods.domain_id = Domains.id AND Goods.is_domain = 0
create table newtb (selct from)
- 通常用于复制表数据
- 新表newtb必须是不存在的表,否则会报错
- 该语法解释时会报错,但不影响执行
CREATE TABLE student3 ( SELECT NAME, salary FROM student );
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11