mysql基础笔记2
创始人
2024-05-03 08:54:50
0

修改数据 
update 数据表名 set 字段=值 where 条件
update stu2 set score=100 where score>80
删除数据 
delete from 表名 where 条件  
备注:如果使用delete 语句后面没有where 子句 会删除数据库中所有的记录
truncate 数据表名 
数据查询
select * (字段名)  from 数据表名
where 条件
group  by 条件 对查询后的结果进行分组 
order by 条件  参数   desc asc 对查询结果进行排序 
having 子句  满足的第二个条件 
(1)使用select 语句查询一个数据表
1select * from user  *  所有的字段 
as 字段起别名 
1.查询所有的字段  *
2.查询指定的字段  select  要查询的字段  from  表名
3查询指定的数据  select where 比较运算符子句 
select * from 表名 where  score between 80 and 100
4.带关键字的in
select 字段*  where 条件  not in (元素1,元素2,元素3)
select *  from stu where not in(70,80,90)
5.between and
6.like  模糊查询
% 多个字符   _ 一个
7.is null 查询空值
select * from stu where score is null
8.and 联合多条件查询
select name from stu where sex='女' and age between 18 and 20 and address like
'北京%' and rich='富有'
9 or 联合 查询
10. 使用关键字 去重查询 
distinct
select distinct 字段 from 表名
select distinct 专业 from stu 
11.使用order by 对查询结果进行排序  
asc  升序  desc 降序 
order by 字段名 asc  
12.group by 
group_concat()函数 将每组所有的记录的字段值都显示 
13.limit 
限制查询输出的数量
select name from stu order by score desc limit 10
14.聚合函数  
(1)count() 返回满足条件的记录的个数 
(2)sum() 求和
(3)avg()平均值
(4)max()最大值
(5)min()最小值
 

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
【PdgCntEditor】解... 一、问题背景 大部分的图书对应的PDF,目录中的页码并非PDF中直接索引的页码...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
修复 爱普生 EPSON L4... L4151 L4153 L4156 L4158 L4163 L4165 L4166 L4168 L4...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...