SQLServer - EXISTS subqueries

First, delete the database

use master
go
if exists (select * from sysdatabases where name = 'Demo')
drop database Demo
go

 

Second, delete the table

use PhoneList
go
if exists (select * from sysobjects where name = 'PCategory')
drop table PCategory
go

 

Third, sub-queries

There follows a list student achievement:

 

Now, there is such a demand, the query C # test scores, if students do not pass exists, this test is more difficult to show, or show moderate content of this examination, the solution is as follows:

(1), use exists

 

(2), using not exists

 

 

 

 

Guess you like

Origin www.cnblogs.com/xulinjun/p/12032116.html