数据库学习笔记(十三)

--内连接
use teaching
select student.studentno, sname, final
FROM student INNER JOIN score
ON student.studentno = score.studentno
WHERE score.courseno = 'c05109'




select student.studentno, sname, usually, final
from student JOIN score
ON student.studentno = score.studentno and usually > 80
where score.courseno = 'c05103'




--左外连接
select student.studentno, sname, usually, final
FROM student LEFT JOIN score
ON student.studentno = score.studentno
where SUBSTRING(student.studentno,1, 2)= '08' 


--子查询


select studentno, sname, point, (select AVG(point) FROM student) as '平均成绩', point - (select AVG(point) from student) as '分数差值'
from student
where studentno = '0828261367'




select studentno, sname, phone, Email
FROM student
WHERE studentno IN (select studentno from score where final > 93) 






--大数的使用方法
BULK INSERT st_score
FROM 'D:\SQLTXT\test101.txt'
WITH (FILELDTERMINATOR = '/')

--插入图片
declare @stno int
BULK insert expic from 'D:\sqltxt\aaa.bmp'
WITH (
FORMATILE = 'D:\sqltxt\file_format.txt'
)




你可能感兴趣的:(数据库学习笔记(十三))