博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
软件测试培训第4天
阅读量:4594 次
发布时间:2019-06-09

本文共 1901 字,大约阅读时间需要 6 分钟。

       继昨天的Mysql数据库的部分查询系统之后,今天则把软件测试中用到的查询命令全部学完,分别是高级查询中的连接查询,联合查询,以及相关子查询。高级查询要比昨天所学的查询复杂不少,命令也比较多,而Mysql的习题难度也非常的大,后面的题目都需要很长一段命令才可以实现,前提必须有十分清晰的思路逐步分解,而紧接着明天也将迎来Mysql的考试,在现在自己还没完全掌握的情况下,明天的考试将会是一场苦战吧……

整理得查询命令:Mysql名词:

创建表:1.字段名2.数据类型3.约束。1和2必须有
表名,字段=条件=条件名,数值
1.简单查询:from后加表名
句型1:select * from 表名;
句型2:select 字段,字段,字段……from 表名;
句型3条件名的修改:select 字段 as 新字段,字段 as 新字段 from 表名;
2.条件查询:where后加字段
句型1:select * from 表名 where 字段="数值";
句型2where后用and连接起两个不同 字段="数值":
       select * from 表名 where 字段="数值" and 字段="数值";
句型3也可用or连接,and和or可以同时使用:
       select * from 表名 where 字段="数值" and 字段="数值" or 字段="数值";
3.模糊查询:where 字段后面+like/not like
句型1(%代表任意多个字符):
       select * from 表名 where 字段 like "%数值";
句型2:(_代表一个字符):
       select * from 表名 where 字段 like "_数值";
4.排序查询:在from 表名之后接 order by 再接字段接desc(降序)/asc(升序默认的)
句型1:select from 表名 order by 字段 desc/asc;
句型2按某字段升+某字段降:
       select from 表名 order by 字段1 asc,字段2desc;
5.范围查询:在字段后接>,<,=,!=,between
句型1用符号表示:
       select from 表名 where 字段>数字 and 字段<数字;
句型2用between表示:
       select from 表名 where 字段 between 数字小 and 数字大;
6.离散查询:where 字段接in("数值")
句型1:select * from 表名 where 字段 in ("数值");
7.聚合函数:select 接函数(字段)
句型1:select 函数(字段)from 表名;
句型2:select 函数(*)from 表名;
8.分页查询:from 表名接limit,where命令后方不可直接加limit
句型1:select * from 表名 limit 数字,数字;
9.去重查询:select后接distinct
句型1:select distinct 字段 from 表名;
10.分组查询:函数后(字段)
句型1:select 接字段,函数(字段)from 表名 group by 字段 having 函数(字段)>,<,=,!=;
11.连接查询:表名1.字段1=表名2.字段2可以这样简化
句型1:select * from 表名 where 表名1.字段1=表名2.字段2 and 表名2.字段=103;
句型2:from 表名接join 表名 on 接表名.字段
       Select * from Teacher
Join course
On Teacher.tno=Course.tno
Join Score
On Course.cno=Score.cno
12.联合查询:两句select语句用union
句型1:select Code,Name from Info
    union
    select Code,Name from Nation;
13.子查询:select(select);
句型1:
      select Code from Nation where Name='汉族'
      select * from Info where Nation = ''
整合:select * from Info where Nation = (select Code from Nation where Name='汉族')

转载于:https://www.cnblogs.com/k874146812-/p/7782189.html

你可能感兴趣的文章
【NOIP2013】提高组
查看>>
E - A Trivial Problem(求满足x!的尾数恰好有m个0的所有x)
查看>>
2015 Multi-University Training Contest 7 hdu 5372 Segment Game
查看>>
POJ 2356 Find a multiple
查看>>
iptables详解
查看>>
HRBUST 1376 能量项链
查看>>
Thread类的使用
查看>>
Unity-NGUI UILabel换行
查看>>
L1-027 出租
查看>>
刷题总结——蚯蚓(NOIP2016DAY2T2)
查看>>
idea @Override is not allowed when implementing interface method
查看>>
javaScript常用知识点有哪些
查看>>
OpenCV调用摄像头 , 人脸检测demo
查看>>
大数据的本质
查看>>
你真的无聊透顶么?不见得
查看>>
软工每日总结30
查看>>
策略模式
查看>>
负载均衡中使用 Redis 实现共享 Session
查看>>
[转载]用纯css改变下拉列表select框的默认样式
查看>>
Content-Type boundary 问题
查看>>