资源预览内容
第1页 / 共5页
第2页 / 共5页
第3页 / 共5页
第4页 / 共5页
第5页 / 共5页
亲,该文档总共5页全部预览完了,如果喜欢就下载吧!
资源描述
Mysql数据库运算符一、 重点回顾:a) 启动Mysql服务b) 使用Navicat进行数据处理c) 如果第一次使用,必须新建一个连接(连接到某个IP地址),需要用户名和密码d) 新建数据库,选择字符集为utf-8e) 创建数据表,定义列名及类型和约束的过程二、 数据管理a) 增:一条语句只能添加一行数据insert into 表名 values(值.);insert into 表名(指定要添加的列) values(值.);b) 删:delete from 表名 where 条件;c) 改:update 表名 set 列=值, 列=值 where 条件;d) 查:select * from 表名 /查询表中所有列的信息select 列名,列名 from 表名 /查询指定列select 列 from 表名 where 条件三、 运算符a) = = != b) and or notc) is null / is not null 不能使用=和空值比较d) in() 绝对相等 not in()e) between . and f) having:用于查询i. 一旦被计算的数据用于条件时,将where换为havingselect 列名 from 表名 where 条件having 条件order by g) 模糊查询:根据关键字,在where 条件中i. _:表示一个字符ii. %:表示0个或多个字符h) 去掉重复数据:select DISTINCT 列名-查询在部门10和部门20中的所有员工select * from emp where deptno=10 or deptno=20select * from emp where deptno in(10,20)-查询工资为1250,1500,1600的员工的姓名和工资select ename,sal from emp where sal=1250 or sal=1500 or sal=1600select ename,sal from emp where sal in(1250,1500,1600)-查询部门10以外的员工信息select * from emp where deptno not in(10)-查询工资在1500到2500之间的所有员工select * from emp where sal=1500 and sal=2000 order by s desc-查询总工资,并显示大于2000的总工资,工资大小3000,总工资降序排序select ename,sal+IFNULL(comm,0) as s from emp where sal3000 having s=2000 order by s desc-查询 员工姓名 是艾 开头的select * from emp where ename like 艾%-查询 员工姓名 是艾 开头,两个字的select * from emp where ename like 艾_-查询第三个字是斯select * from emp where ename like _斯-查询人名字中有斯 的select * from emp where ename like %艾% and job like %销售%
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号