電子工業出版社 JSHING HOUSE DF ELECTRONCS INDSTE 此例中,首先, SELECt advance FRoM publishers INNEr Join titles on titles.pubi publishers. pub id and pub name=' New moon books’子查询返回了 New Moon books 出版社的所有书籍的预付款(2000.000,2275.0000,400000,6000.0000,10125.0000),而 AL关键字的含义是每一个值,所以>ALL的取值为大于集合中的最大值,即》10125.0000 然后外部查询 select title, advance from titles Where advance10125.000语句查询 出最后结果。 【例638】在样例数据库pubs中,查询出版过 psychology类型的书籍的出版社名单 USE pubs SELECT a* FROM publishers WHERE EXISTS (SELECT FROM titles Where pub id =publishers. pub id AND type psychology') 运行结果: pub id pub name Ity state country New Moon books Boston MA USA 0877 Binnet Hardley Washington DC USA (所影响的行数为2行) 此例中,首先, EXISTS( SELECT* From titles Where pub id= publishers. pub id ANd type=' psychology')子査询测试是否存在出版过 psychology类型书籍的出版社,如 果存在,则外部查询从 publisher表中查询出该出版社的信息。此例中,首先,SELECT advance FROM publishers INNER JOIN titles ON titles.pub_id = publishers.pub_id AND pub_name = 'New Moon Books'子查询返回了 New Moon Books 出版社的所有书籍的预付款(2000.0000,2275.0000,4000.0000,6000.0000,10125.0000),而 ALL 关键字的含义是每一个值,所以>ALL 的取值为大于集合中的最大值,即>10125.0000; 然后外部查询 SELECT title, advance FROM titles WHERE advance>10125.0000 语句查询 出最后结果。 【例 6.38】在样例数据库 pubs 中,查询出版过 psychology 类型的书籍的出版社名单。 USE pubs SELECT * FROM publishers WHERE EXISTS (SELECT * FROM titles WHERE pub_id = publishers.pub_id AND type = 'psychology') 运行结果: pub_id pub_name city state country ------ ---------------------------------------- ------------- 0736 New Moon Books Boston MA USA 0877 Binnet & Hardley Washington DC USA (所影响的行数为 2 行) 此例中, 首先,EXISTS (SELECT * FROM titles WHERE pub_id = publishers.pub_id AND type = 'psychology')子查询测试是否存在出版过 psychology 类型书籍的出版社,如 果存在,则外部查询从 publisher 表中查询出该出版社的信息