标签:sno 查询 sc MySQL DQL where 连接 select
数据查询的语法结构
select 子句1
from 子句2
[where 表达式1]
[group by 子句3]
[having 表达式2]
[order by 子句4]
[union 运算符]
[into outfile 输出文件名]
[limit [m,]n];
limit [m,] n :m是结果集中的下标,n是查询数量
1、匹配符like
通配符
- %:任意多个字符,M%,%M,%M%
- _:单个字符,_M
当匹配串不包含通配符,用=取代like,用<>取代not like
2、正则表达式
where 字段名 regexp '模式串'
3、空值查询
where 字段 is [not] null
4、连接查询
- 交叉连接
select [all | distinct] * from table1,table2
- 内连接
select A.*, B.*
from student A, sc B
where A.sno = B.sno;
或者
select A.*, B.*
from student A inner join sc B on A.sno = B.sno;
- 自连接
select A.sno
from sc A, sc B
where A.sno = B.sno and A.cno = 'C01' and B.cno = 'C04';
- 外连接:左外连接、右外连接、全外连接
select [all | distinct] *
from table1 left|right|full[outer] join table2
on table1.sno = table2.sno;
5、嵌套查询
- 不相关子查询
- 子查询返回单值:=
- 子查询返回值列表:in 、not in 、any、 some 、all
- 相关子查询:子查询依赖父查询
select sname
from student
where exists(
select *
from sc
where sno = student.sno and cno='C01';
)
6、集合查询
union intersect minus
参考资料:《MySQL数据库原理及应用》武洪萍
标签:sno,查询,sc,MySQL,DQL,where,连接,select 来源: https://blog.csdn.net/qq_35334269/article/details/106250439
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。