電子工業出版社 SHING HOUSE DF ELECTRONY 【例6.13】从样例数据库pubs的 titles表中查询书价( price列)大于15的所有图书 USE pub SELECT title, price WHERE price>15 运行结果: The Busy Executive s Database Guide Straight Talk About Computers Silicon Valley Gastronomic Treats Secrets of Silicon Valley 20.0000 Computer Phobic AND Non-Phobic Individuals: Behavior variations Prolonged Data Deprivation: Four Case Studie 19. Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean (所影响的行数为8行) 查询结果显示表ttes中书价大于15的所有的图书。 【例614】从样例数据库pubs的tes表中查询书籍类型(type列)为 business的所有 图书 USE pubs SeLECt title, type titl e type= business 行结果 title type The Busy Executive s Database Guide Cooking with Computers: Surreptitious Balance Sheets business You Can Combat Computer Stress! Straight Talk About Computers business (所影响的行数为4行) 查询结果显示表tls中书籍类型(type列)为 business的所有图书。 【例615】从样例数据库pubs的tits表中查询书价( price列)在15与20之间的所 有图书
【例 6.13】从样例数据库 pubs 的 titles 表中查询书价(price 列)大于 15 的所有图书。 USE pubs SELECT title, price FROM titles WHERE price>15 运行结果: title price -------------------------------------------------------------------------------- The Busy Executive's Database Guide 19.9900 Straight Talk About Computers 19.9900 Silicon Valley Gastronomic Treats 19.9900 But Is It User Friendly? 22.9500 Secrets of Silicon Valley 20.0000 Computer Phobic AND Non-Phobic Individuals: Behavior Variations 21.5900 Prolonged Data Deprivation: Four Case Studies 19.9900 Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean 20.9500 (所影响的行数为 8 行) 查询结果显示表 titles 中书价大于 15 的所有的图书。 【例 6.14】从样例数据库 pubs 的 titles 表中查询书籍类型(type 列)为 business 的所有 图书。 USE pubs SELECT title, type FROM titles WHERE type='business' 运行结果: title type ------------------------------------------------------------------- The Busy Executive's Database Guide business Cooking with Computers: Surreptitious Balance Sheets business You Can Combat Computer Stress! business Straight Talk About Computers business (所影响的行数为 4 行) 查询结果显示表 titles 中书籍类型(type 列)为 business 的所有图书。 【例 6.15】从样例数据库 pubs 的 titles 表中查询书价(price 列)在 15 与 20 之间的所 有图书
電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR USE pubs SELECT title, price RoM title Where price BETWEEN 15 AND 20 行结果 title price The Busy Executive s Database Guide 19.9900 raight Talk About Computers 19.9900 Silicon Valley Gastronomic Treats Secrets of silicon Valley Prolonged Data Deprivation: Four Case Studies 19.9900 (所影响的行数为5行) 查询结果显示表 titles中书价在15与20之间的所有图书。 【例616】从样例数据库pubs的ttes表中查询书价( price列)不在15与20之间的 所有图书 SeleCt title, price FROM titles Where price NOT BETWEEN 15 AND 20 price Cooking with Computers: Surreptitious Balance Sheets 11 9500 You Can Combat Computer Stress! The gourmet microwave Fifty Years in Buckingham Palace Kitchens Sushi, Anyone? 14.9900 (所影响的行数为11行) 查询结果显示表 titles中书价不在15与20之间的所有图书。 【例617】从样例数据库pubs的 titles表中查询书籍类型为 business和 psychology的所 有图书 USE pubs SeLECt title, type
USE pubs SELECT title, price FROM titles WHERE price BETWEEN 15 AND 20 运行结果 title price ----------------------------------------------------------- The Busy Executive's Database Guide 19.9900 Straight Talk About Computers 19.9900 Silicon Valley Gastronomic Treats 19.9900 Secrets of Silicon Valley 20.0000 Prolonged Data Deprivation: Four Case Studies 19.9900 (所影响的行数为 5 行) 查询结果显示表 titles 中书价在 15 与 20 之间的所有图书。 【例 6.16】从样例数据库 pubs 的 titles 表中查询书价(price 列)不在 15 与 20 之间的 所有图书。 USE pubs SELECT title, price FROM titles WHERE price NOT BETWEEN 15 AND 20 title price ------------------------------------------------------------------------ Cooking with Computers: Surreptitious Balance Sheets 11.9500 You Can Combat Computer Stress! 2.9900 The Gourmet Microwave 2.9900 ... ... Fifty Years in Buckingham Palace Kitchens 11.9500 Sushi, Anyone? 14.9900 (所影响的行数为 11 行) 查询结果显示表 titles 中书价不在 15 与 20 之间的所有图书。 【例 6.17】从样例数据库 pubs 的 titles 表中查询书籍类型为 business 和 psychology 的所 有图书。 USE pubs SELECT title, type
電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR FROM titles Where type In (business,' psychology') 运行结果 title The Busy Executive s Database Guide Cooking with Computers: Surreptitious Balance Sheet You Can Combat Computer Stress business Prolonged Data Deprivation: Four Case Studies psychology Emotional Security: A New Algorithm psychology (所影响的行数为9行) 查询结果显示表tt中书籍类型为 business和 psychology的所有图书。 【例618】从样例数据库pubs的ts表中查询书籍类型不为 business和 psychology的 所有图书 SELECt title, type FROM titles Where type NOT IN (business, psychology 运行结果: Silicon Valley Gastronomic Treats The Gourmet Microwave The Psychology of Computer Cooking UNDECIDED Fifty Years in Buckingham Palace Kitchens trad_ cook Sushi, Anyone? trad cook (所影响的行数为9行) 查询结果显示表tls中书籍类型不为 business和 psychology的所有图书 【例619】从样例数据库pubs的ts表中查询书名ttle列)以S开头的的所有图书。 USE pubs SeLECt title, type ROM title
FROM titles WHERE type IN ('business', 'psychology') 运行结果: title type ----------------------------------------------------------------------------- The Busy Executive's Database Guide business Cooking with Computers: Surreptitious Balance Sheets business You Can Combat Computer Stress! business ... ... Prolonged Data Deprivation: Four Case Studies psychology Emotional Security: A New Algorithm psychology (所影响的行数为 9 行) 查询结果显示表 titles 中书籍类型为 business 和 psychology 的所有图书。 【例 6.18】从样例数据库 pubs 的 titles 表中查询书籍类型不为 business 和 psychology 的 所有图书。 USE pubs SELECT title, type FROM titles WHERE type NOT IN ('business', 'psychology') 运行结果: title type ----------------------------------------------------------- Silicon Valley Gastronomic Treats mod_cook The Gourmet Microwave mod_cook The Psychology of Computer Cooking UNDECIDED ... ... Fifty Years in Buckingham Palace Kitchens trad_cook Sushi, Anyone? trad_cook (所影响的行数为 9 行) 查询结果显示表 titles 中书籍类型不为 business 和 psychology 的所有图书。 【例 6.19】从样例数据库 pubs 的 titles 表中查询书名(title 列)以 S 开头的的所有图书。 USE pubs SELECT title, type FROM titles
電子工業出版社 JEUISHING HOUSE DF ELECTRONCS INDSTR Where title liKe $% 运行结果 title Secrets of Silicon Valley popular comp Silicon Valley Gastronomic Treats Straight Talk About Computers business Sushi, An (所影响的行数为4行) 查询结果显示表 titles中书名以S开头的的所有图书。 【例620】从样例数据库pubs的tes表中查询书名tte列)以S开头,书名的第2个 字符为u或i的所有图书 USE pubs SELECT title, type Where title like 'Sliu% 行结果 type Silicon Valley Gastronomic Treats mod cook Sushi, Anyone? (所影响的行数为2行) 查询结果显示表ttes中书名以S开头,书名的第2个字符为u或i的所有图书。 【例621】从样例数据库pubs的tts表中查询书名tite列)以S开头,书名的第3个 字符为1的所有图书。 USE pubs SELECT title, type WherE title liKe'S1%” 运行结果 Silicon Valley Gastronomic Treats mod cook (所影响的行数为1行
WHERE title LIKE 'S%' 运行结果: title type --------------------------------------------------------- Secrets of Silicon Valley popular_comp Silicon Valley Gastronomic Treats mod_cook Straight Talk About Computers business Sushi, Anyone? trad_cook (所影响的行数为 4 行) 查询结果显示表 titles 中书名以 S 开头的的所有图书。 【例 6.20】从样例数据库 pubs 的 titles 表中查询书名(title 列)以 S 开头,书名的第 2 个 字符为 u 或 i 的所有图书。 USE pubs SELECT title, type FROM titles WHERE title LIKE 'S[iu]%' 运行结果: title type ----------------------------------------------------- Silicon Valley Gastronomic Treats mod_cook Sushi, Anyone? trad_cook (所影响的行数为 2 行) 查询结果显示表 titles 中书名以 S 开头,书名的第 2 个字符为 u 或 i 的所有图书。 【例 6.21】从样例数据库 pubs 的 titles 表中查询书名(title 列)以 S 开头,书名的第 3 个 字符为 l 的所有图书。 USE pubs SELECT title, type FROM titles WHERE title LIKE 'S_l%' 运行结果 title type ------------------------------------------------- Silicon Valley Gastronomic Treats mod_cook (所影响的行数为 1 行)
電子工業出版社 JSHING HOUSE DF ELECTRONCS INDSTE 查询结果显示表 titles中书名以S开头,书名的第3个字符为1的所有图书 【例622】从样例数据库pubs的ttes表中查询书名ttle列)不是以S开头的的所有图 书 SeLECt title, type FRoM titles Where title not like $% 运行结果 t e t The Busy Executive s Database Guide You Can Combat Computer Stress Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean trad cook Fifty Years in Buckingham Palace Kitchens trad cook (所影响的行数为14行) 查询结果显示表 titles中书名不是以S开头的的所有图书
查询结果显示表 titles 中书名以 S 开头,书名的第 3 个字符为 l 的所有图书。 【例 6.22】从样例数据库 pubs 的 titles 表中查询书名(title 列)不是以 S 开头的的所有图 书。 USE pubs SELECT title, type FROM titles WHERE title NOT LIKE 'S%' 运行结果: title type ---------------------------------------------------------------------------- The Busy Executive's Database Guide business Cooking with Computers: Surreptitious Balance Sheets business You Can Combat Computer Stress! business ... ... Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean trad_cook Fifty Years in Buckingham Palace Kitchens trad_cook (所影响的行数为 14 行) 查询结果显示表 titles 中书名不是以 S 开头的的所有图书