SQL语句汇总

/********
SQL单表查询条件汇总
/
1,
where grade>=60;
2,where sage between 20 and 22;
3,where sage not between 20 and 22;
4,where sdept in(‘计算机学院’,‘交通学院’,‘机械学院’);/// 谓词in 后可以跟多个值。
5,where sdept not in(‘计算机学院’,‘交通学院’,‘机械学院’);
///使用谓词Like进行字符串匹配查找
6,where sno like ‘17110203043’===where son=‘1710203043’;
///在Like中涉及两个通配符%和_
///a%b表示以a开头以b结尾的字符串,a%表示以a开头的字符串…
///下划线_表示任意"一个"字符。for example:a_表示以a开头的且长度为2的字符串。
7,where sname not like ‘董%’;
8,where grade is null;///查询选课但成绩为空的学生。
9,where sdept='计算机学院’and sage>20;
10,order by grade desc;
11,group by son having count(
)>6;
/
*****
SQL连接查询
内连接:等值连接,自然连接
外连接:左外连接,右外连接,全连接
自身链接
/
1,where student.sno=sc.son and sc.sno=2 and sc.grade>95;///等值连接,将Student与sc 中同一学生的元组连接起来
2,select from student natural join sc ;///自然连接不许指定具体列,默认。
3,select from student left outer join sc using (sno);///左外连接,使用using 可以去除重复组。
4,select l
from course s1,course s2 where s1.cno=s2.spno;///自身连接,使用别名。
/
*
SQL嵌套查询
******************/
单表查询的组合,省略。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值