专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

Mysql(条件查询)

(1)关键字and or > < = >= <= between ….and not between…and

select sname
from Student
where studentno='2017151'

(2)属性 in(A,B,C,……)–>属性 = A or 属性=B or 属性= C……

select sname ,studentno  
from Student 
where point in(777,789,799)

(3)like:只用于文本匹配查询

select sname   --查询姓刘的学生,%为任意个数的字
from Student 
where sname like '刘%'
select sname   --查询刘aa,名字为两个字,_为一个字
from Student 
where sname like '刘__'

如在匹配中遇到_或%,则需要在前面加/转义

(4)条件查询中如果某一属性为空,用 is NULL

select  studentno,sname,classno
from student
where email is null

(5)聚集函数

COUNT:统计一列中值的个数

SUM:计算一列值的总和

AVG:平均值

MAX:最大值

MIN:最小值

select MIN(point) MIN,MAX(point) 
from student

(6)group by

select MIN(point) MIN,MAX(point) MAX
from student
group  by classno

(7)HAVING作用对象为组,跟在GROUP BY 后

select studentno
from score
group by studentno
having COUNT(courseno)>=3 

文章永久链接:https://tech.souyunku.com/22438

未经允许不得转载:搜云库技术团队 » Mysql(条件查询)

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们