1、增

语法:insert into 表 (列名,列名...) values (值,值...)

# 插入单条数据
insert into 表 (列名,列名...) values (值,值...)

# 插入多条数据
insert into 表 (列名,列名...) values (值,值...),(值,值...)

# 插入另一条语句的查询结果
insert into 表 (列名,列名...) select 列名,... from 表

2、删

语法:delete from 表

delete from 表;
delete from 表 where id=;

3、改

语法:update 表 set name = 'nick' where id>1

update 表 set name = 'nick' where id>

4、查

语法:select * from 表

select * from 表
select * from 表 where id >
select nid,name,gender as gg from 表 where id > # as 做别名

5、条件

语法:select * from 表 where id > 1

    select * from 表 where id >  and name != 'nick' and num = ;    # 多个条件
select * from 表 where id between and ; # id在5到16之间
select * from 表 where id in (,,); # id在元祖中
select * from 表 where id not in (,,); # id不在元祖中
select * from 表 where id in (select nid from 表); # id在查询结果中

6、通配符

语法:select * from 表 where name like '_n%'

  select * from 表 where name like 'ni%'  # ni开头的所有(多个字符串)
select * from 表 where name like 's_' # s开头的所有(一个字符)

7、限制

语法:select * from 表 limit 9,5;

    select * from 表 limit 5;            # 前5行
select * from 表 limit 9,5; # 从第9行开始的5行
select * from 表 limit 5 offset 9 # 从第9行开始的5行

8、排序

语法:select * from 表 order by 列1 desc,列2 asc

    select * from 表 order by 列 asc             # 根据 “列” 从小到大排列
select * from 表 order by 列 desc # 根据 “列” 从大到小排列
select * from 表 order by 列1 desc,列2 asc # 根据 “列1” 从大到小排列,如果相同则按列2从小到大排序

9、分组

语法:select num from 表 group by num

    select num from 表 group by num           # 根据num分组
select num,nid from 表 group by num,nid # 根据num和nid分组
select num,nid from 表 where nid > 10 group by num,nid order nid desc
select num,nid,count(*),sum(score),max(score),min(score) from 表 group by num,nid # 内置函数
select num from 表 group by num having max(id) > 10 # 前面计算的结果交由后面处理 注:group by 必须在where之后,order by之前
count(*)、count(1) # 表示个数
sum(score)   # 表示和
max(score)   # 表示最大数
min(score)   # 表示最小数 having # 要用前面处理结果是用having。

10、连表

语法:inner join . onleft join . onright join . on

    无对应关系则不显示
select A.num, A.name, B.name
from A,B
Where A.nid = B.nid 无对应关系则不显示
select A.num, A.name, B.name
from A inner join B
on A.nid = B.nid A表所有显示,如果B中无对应关系,则值为null
select A.num, A.name, B.name
from A left join B
on A.nid = B.nid B表所有显示,如果B中无对应关系,则值为null
select A.num, A.name, B.name
from A right join B
on A.nid = B.nid

11、组合

语法:union、union all

    组合,自动处理重合
select nickname
from A
union
select name
from B 组合,不处理重合
select nickname
from A
union all
select name
from B

参考:https://www.cnblogs.com/suoning/articles/5769141.html

mysql_表内容_操作的更多相关文章

  1. mysql(三) 数据表的基本操作操作

    mysql(三) 数据表的基本操作操作 创建表,曾删改查,主键,外键,基本数据类型. 1. 创建表 create table 表名( 列名 类型 是否可以为空, 列名 类型 是否可以为空 )ENGIN ...

  2. mysql_表_操作

    1.创建表 # 基本语法: create table 表名( 列名 类型 是否可以为空 默认值 自增 主键, 列名 类型 是否可以为空 )ENGINE=InnoDB DEFAULT CHARSET=u ...

  3. 第二百七十八节,MySQL数据库-表内容操作

    MySQL数据库-表内容操作 1.表内容增加 insert into 表 (列名,列名...) values (值,值,值...); 添加表内容添加一条数据 insert into 表 (列名,列名. ...

  4. MySQL数据库-表内容操作

    1.表内容增加 insert into 表 (列名,列名...) values (值,值,值...); 添加表内容添加一条数据 insert into 表 (列名,列名...) values (值,值 ...

  5. mysql_用户_操作

    一. 创建用户 登录MySQL mysql -u root -p 添加新用户 create user 'username'@'host' identified by 'password'; usern ...

  6. [刘阳Java]_MyBatis_其他方式来实现多表查询的操作_第9讲

    MyBatis其他方式来实现多表查询的操作 利用Java中的集合框架(List,Map) 其中List存储多个查询返回的记录 Map查询返回字段,同时记录表中一条数据 <?xml version ...

  7. OCM_第三天课程:Section1 —》表空间的操作和管理、服务配置

    注:本文为原著(其内容来自 腾科教育培训课堂).阅读本文注意事项如下: 1:所有文章的转载请标注本文出处. 2:本文非本人不得用于商业用途.违者将承当相应法律责任. 3:该系列文章目录列表: 一:&l ...

  8. oracle表结构和表内容差异比对

    oracle表结构和表内容差异比对 oracle中有三种集合操作,他们会把左边和右边的select 结果集进行集合操作. union 并集 intersect 交集 minus 差集 假设有如下两张表 ...

  9. PHP数组/Hash表的实现/操作、PHP变量内核实现、PHP常量内核实现 - [ PHP内核学习 ]

    catalogue . PHP Hash表 . PHP数组定义 . PHP变量实现 . PHP常量实现 1. PHP Hash表 0x1: 基本概念 哈希表在实践中使用的非常广泛,例如编译器通常会维护 ...

随机推荐

  1. python-循环(loop)-for循环

    for 循环 for every_letter in 'Hello world': print(every_letter) 输出结果为 把 for 循环所做的事情概括成一句话就是:于...其中的每一个 ...

  2. Navicat Premium 快捷键

    1.ctrl+q 打开查询窗口2.ctrl+/ 注释sql语句3.ctrl+shift +/ 解除注释4.ctrl+r 运行查询窗口的sql语句5.ctrl+shift+r 只运行选中的sql语句6. ...

  3. linux中的系统服务--daemon

    简单的说,系统为了某些功能必须要提供一些服务 (不论是系统本身还是网络方面),这个服务就称为 service . 但是 service 的提供总是需要程序的运行吧!否则如何运行呢?所以达成这个 ser ...

  4. vim跳出括号的方法

    https://github.com/Raimondi/delimitMate delimitMate是一个自动括号补全的好插件,但是,如果没有一个好的跳出括号办法,好想由打了折扣. 我目前找到最适合 ...

  5. iOS网络访问之使用AFNetworking

    AFNetworking是IOS上常用的第三方网络访问库,我们可以在github上下载它,同时github上有它详细的使用说明,最新的AFNetworing2.0与1.0有很大的变化,这里仅对2.0常 ...

  6. url参数

    两个参数情况: String url="http://59.78.93.208:9097/Order?id="+id+"&value="+value; ...

  7. Vmware虚拟机修改静态IP无法ping外网,以及eth0不见问题解决

    1. 修改静态地址后发现无法ping外网 要先把/etc/sysconfig/network-scripts/ifcfg-eth0中的网关设置成192.168.230.2. 需要设置网关 sudo r ...

  8. 12 jsp page 指令

    jsp 指令影响由 jsp 页面生成的 servlet 整体结构. jsp page 用来设置整个页面属性, 例如 import 就是引用这些类, 还可以设置 session 等等. <%@ p ...

  9. 马尔科夫毯(Markov Blanket)

    最优特征子集:选出特征的子集,能够比较准确的代表原来的特征.马尔科夫毯(MB)是贝叶斯网络(BN)的最有特征子集. 推测贝叶斯网络的网络结构是NP问题.贝叶斯网络中一个节点T的马尔科夫毯是其父节点,子 ...

  10. 第二百三十二节,Bootstrap排版样式

    Bootstrap排版样式 学习要点: 1.页面排版 本节课我们主要学习一下 Bootstrap 全局 CSS 样式中的排版样式,包括了标题.页面 主体.对齐.列表等常规内容. 一.页面排版 Boot ...