10-7 3-2-(b)查询由生产厂商B生产的所有产品的型号(model) 和价格(price) (10 分)
生活随笔
收集整理的這篇文章主要介紹了
10-7 3-2-(b)查询由生产厂商B生产的所有产品的型号(model) 和价格(price) (10 分)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1.查詢由生產(chǎn)廠商B生產(chǎn)的所有產(chǎn)品的型號(model) 和價格(price) (10 分)
-- 查詢由生產(chǎn)廠商B生產(chǎn)的所有產(chǎn)品的型號(model) 和價格(price)。 -- 提示:查詢按照pc、laptop和printer的順序進行。 -- union:是連接多個查詢的語句 -- 還有就是這里的 in () 括號中不可添加為('1006','3002')select model,price from pcwhere model in (select model from product where maker = 'B') union select model,price from laptopwhere model in (select model from product where maker = 'B') union select model,price from printerwhere model in (select model from product where maker = 'B')2:查詢所有出售便攜式電腦(而不出售PC機)的生產(chǎn)廠商 (10 分)
-- 查詢所有出售便攜式電腦(而不出售PC機)的生產(chǎn)廠商。 -- 解釋:個人電腦也就是pc機 laptop是便攜式電腦-- 分析:1.求出所有出售便攜式電腦的廠商 (d,e) -- 2.求出所有出售pc機的廠商(a,d) -- 3.找出(d,e)不在(a,d)當中的當中的廠商-- -- 便攜式 select DISTINCT product.maker from laptop,productwhere laptop.model = product.modeland product.maker not in (select maker from pc,productwhere pc.model = product.model);3:查詢在兩種或兩種以上PC機上出現(xiàn)的硬盤容量 (10 分)
-- 查詢在兩種或兩種以上PC機上出現(xiàn)的硬盤容量。-- 分析:1.先按硬盤容量進行分組 -- 2.在將其作為子表-- select hd,count(*) from pc -- group by hd;select temp.hdfrom (select hd,count(*) as num from pcgroup by hd) tempwhere temp.num >= 2;4:查詢擁有相同速度和內(nèi)存的PC機的成對的型號 (10 分)
select temp1.model as model1,temp2.model as model2from pc temp1,pc temp2where temp1.speed = temp2.speedand temp1.ram = temp2.ramand temp1.model < temp2.model5. 查詢電影“M3”中的男影星 (10 分)
-- 多表查詢 條件是 演員的姓名進行聯(lián)系兩個表 -- 然后就是 演員表當中性別為男-- select name -- from StarsIn,MovieStar -- where starName = name -- and gender = 'M' -- and movieTile = 'M3';-- 用到了多行子查訊 -- select starName from MovieStar -- where movieTile = 'M3';select namefrom MovieStarwhere name in (select starName from StarsInwhere movieTitle = 'M3')and gender = 'M';6:查詢st1制片公司的總裁 (10 分)
select MovieExec.namefrom MovieExec,Studiowhere certID = presCertIDand Studio.name = 'st1';7:`查詢在st1公司于2018年制作的電影中出演的影星 (10 分)
-- 查詢在st1公司于2018年制作的電影中出演的影星。-- 分析:1.查詢st1公司2018年制作了哪些電影在movie表當中 -- 2.然后在將其上方的查詢結(jié)果作為子查詢 在StarsIn表中-- select title from Movie -- where studioName = 'st1' -- and year = 2018;SELECT DISTINCT starNameFROM StarsInWHERE movieTitle IN (SELECT title FROM MovieWHERE studioName = 'st1'AND YEAR = 2018) and movieYear = 2018; 創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的10-7 3-2-(b)查询由生产厂商B生产的所有产品的型号(model) 和价格(price) (10 分)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 铭凡推出 NAG6 迷你主机:i9-12
- 下一篇: leedcode04:转换字符串的最少操