约束查询

数据库查询语句
       
             【 一 】
 
1、检索student2010表中学制(XZ)为年的学生信息
--select * from student2010 where xz = '2'
 

2、检索course表中学分(credit)小于的所有课程
--select * from course where credit < '3'
 

3、检索course表中学分(credit)在.5和之间的所有课程
--select * from course where credit between '2.5' and '4'
 

4、检索course表中学分(credit)小于2.5或大于4的所有课程
--select * from course where credit not between '2.5' and '4'
 

5、检索student2010表中班级名称(BJMC)为“计算机网络技术班”的学生信息
--select * from student2010 where BJMC = '2010计算机网络技术班'
 

6、检索stucou表中选了课程编号从005到012的所有记录
--select * from stucou where couno between '005' and '012'
 

7、检索stucou表中没有选修课程编号从005到012的所有记录
--select * from stucou where couno not between '005' and '012'
 

8、检索student2010表中和你同一个市的学生信息
--select * from student2010 where jtdz like '%韶关市'
 

9、检索student2010表中专业名称(ZYMC)为“计算机网络技术”的学生信息,只显示学号、姓名、班级三列
--select XH,XM,BJMC from student2010  where ZYMC = '计算机网络技术'
 

10、检索student2010表中专业名称(ZYMC)为“计算机网络技术”的学生的学号、姓名字段,字段名用中文显示
--select XH AS 学号,XM AS 姓名from student2010  where ZYMC = '计算机网络技术'
 

11、检索stucou表中选修了、'004','009','010','015'、及课程的记录
--select * from stucou where couno in ('004','009','010','015')
 

12、显示student2010表中的所有系部名称(不重复显示)
--select distinct xymc from student2010
 

13、显示stucou表中所有willorder为1且couno为003的记录
--select * from stucou where willorder='1' and couno='003'
 

14、检索student表中你的记录行
--select * from student where stuname = '钟红连'
 

15、检索student表中和你同姓的记录行
--select * from student where stuname like '钟%'
 

16、显示stucou表中所有willorder为2到4的记录
--select * from stucou where willorder between '2' and '4'
 

17、显示student表中所有姓张、李、刘的记录
--select * from student where stuname like '[张,李,刘]%'
 

18、显示student表中所有姓张、李、刘记录的学号、姓名两个字段
--select stuno,stuname from student where stuname like '[张,李,刘]%'
原文地址:https://www.cnblogs.com/xiaoyumi666/p/6029918.html