第一范文网 - 专业文章范例文档资料分享平台

MySQL基础 学习 超级详细

来源:用户分享 时间:2025/6/28 13:27:18 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

select*from表orderby列asc-根据“列”从小到大排列 select*from表orderby列desc-根据“列”从大到小排列

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

4.3、模糊查询

通配符(模糊查询)

select*from表where name like'ale%'- ale开头的所有(多个字符串) select*from表where name like'ale_'- ale开头的所有(一个字符)

4.4、聚集函数查询

聚集函数 4.5、分组查询

分组

select num from表groupby num selectnum,nidfrom表groupby num,nid

selectnum,nidfrom表where nid >10groupby num,nid order nid desc

selectnum,nid,count(*),sum(score),max(score),min(score) from表groupby num,nid

select num from表groupby num havingmax(id) >10

特别的:groupby必须在where之后,order by之前

4.6多表查询

a、连表

无对应关系则不显示

select A.num, A.name, B.name fromA,B

Where A.nid = B.nid

无对应关系则不显示

select A.num, A.name, B.name from A innerjoin B on A.nid = B.nid

A表所有显示,如果B中无对应关系,则值为null select A.num, A.name, B.name

from A leftjoin B on A.nid = B.nid

B表所有显示,如果B中无对应关系,则值为null select A.num, A.name, B.name from A rightjoin B on A.nid = B.nid b、组合

组合,自动处理重合 select nickname from A union

select name from B

组合,不处理重合 select nickname from A unionall select name from B

搜索更多关于: MySQL基础 学习 超级详细 的文档
MySQL基础 学习 超级详细.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1w22l5lm970wk4t3v4f03ibqw7s1xb00tmb_5.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top