1、IN谓词子查询:

select Sno,Sname,Sdept

from Student

where sdept IN

(select Sdept

from Student

where Sname =’WANG’);

select Sno,Sname

from Student

where Sno IN

(select Sno

from SC

where Cno IN

(select Cno

from Course

where Cname =’shujuku4′)

);

2、ANY(SOME)或ALL谓词子查询:

select Sname,Sage

from Student

where Sage < ANY (select Sage

from Student

where Sdept =’CS’)

AND Sdept <> ‘CS’;

3、EXISTS谓词子查询:

select Sname

from Student

where EXISTS

(select *

from SC

where Sno =Student.Sno AND Cno=’1′);

select DISTINCT Sno

from SC SCX

where NOT EXISTS

(select *

from SC SCY

where SCY.Sno =’1002′ AND NOT EXISTS

(select *

from SC SCZ

where SCZ.Sno = SCX.Sno AND

SCZ.Cno = SCY.Cno));

Tags: , ,

Related posts

Tags: ,,.
Home

No Comments Now!

Be the first to comment on this entry.

Leave a comment

Name(required)
Mail (required),(will not be published)
Website(recommended)

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URLs must be fully qualified (eg: http://hanghang.name),and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.