常用sql语句
来源:互联网 发布:单片机多路压力采集 编辑:程序博客网 时间:2024/06/06 01:01
- 插入单行
insert into <表名> values (列值) - 将现有数据添加到某个已有的表中
insert into <被添加表名>(列,列,列) select 列,列,列 from <现有表名> - 将现有数据填充一个新表
select 列,列,列 into <新建表名> from <现有表名> - 插入多行
insert <表名>(列,列,列)
select 列,列,列 union
select 列,列,列
删除行
delete from <表名> where 条件删除表
drop table tablename 删除内容及定义 ,释放空间
truncate table tablename 删除内容,但不删除定义
delete table where 条件 删除符合条件的内容
- 修改表
update <表名> set 列名=更新值 where 条件
- 查询所有
select * from 表名 - 部分查询
select 列,列,列 from 表名 where 条件 - 精确查询
select 列,列,列 from 表名 where 条件 order by 需排序的列名asc/desc - 查询并更改列名
select 列 as 新列名 from 表名 where 条件 查询空行
select 列 from 表名 where 条件=null查询中使用常量
select 列, 变量名 as 新列名 from 表名 //查询并显示表列,并添加新列,值为“变量名”限制返回数量
select top num 列 from 表名 //显示前num行
select top num percent 列 from 表名 //显示其num%
like进行字符串的模糊查询
select * from 表名 where 列名 like ‘张三’使用between进行范围内的查询
select * from 表名 where 列名 between num1 and num2使用in进行枚举查询
select 列 from 表名 where 列名 in (值,值,值)使用group by进行分组筛选
select 列 as 新列名, 列 as 新列 from 表名 group by 列使用having进行分组筛选
select 列 as 新列名, 列 as 新列 from 表名 group by 列 having 条件
查询多表
select a.name,b.age from a,b where a.name=b.name内联接查询
select a.name,b.age from a inner join b on ( a.name=b.name)外联接查询(左右)
select a.name,b.age from a left outer join b on ( a.name=b.name)
select a.name,b.age from a right outer join b on ( a.name=b.name)
- SQL语句 常用语句
- sql常用sql语句
- SQLite 常用语句 sql语句
- oracle常用SQL语句
- DBA常用SQL语句
- DBA常用SQl语句
- 常用SQL语句
- 常用SQL语句
- oracle常用SQL语句
- oracle常用SQL语句
- 管理常用SQL语句
- 管理常用SQL语句
- 管理常用SQL语句
- 常用SQL语句(Update)
- 常用SQL语句
- SQL常用语句大全
- 常用sql语句1
- 常用Sql语句
- 学习java第一天
- java时间差计算
- 628. Maximum Product of Three Numbers
- Hdu 4203 Doubloon Game 博弈+打表
- QML之自定义电池充电/电量显示效果
- 常用sql语句
- 阿里云ECS-centos6.8下 安装配置mysql5.7
- 《Java编程思想读书笔记》--对象导论
- MySQL删除外键约束
- Spring-boot实例学习之 Command line application单元测试
- 冒泡排序
- 欢迎使用CSDN-markdown编辑器
- Nand Flash基础知识与坏块管理机制的研究
- python实现猜数字游戏