嵌套查詢

http://www.cnblogs.com/kissdodog/archive/2013/06/03/3116284.htmlhtml

select name,age from person where  age > (select age from person where name = '曹操')   //從person中查詢name和age,前提條件是年齡要大於姓名=曹操的年齡;
select name from person where countryid in (select countryid from country  where countryname = '魏國')  //從person表中查詢name值,前提條件countryid是countryname = '魏國'的countryid
select name from person where countryid = some (select countryid from country  where countryname = '魏國') //從person表中查詢name值,前提條件countryid在XX中
select name from person where countryid > all (select countryid from country  where countryname = '魏國') //countryid大於countryname='魏國'的數據
SELECT * FROM Person WHERE  exists (SELECT * FROM Person WHERE Person_Id = 100 )
相關文章
相關標籤/搜索