![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据库查询--计算机、电脑系列
不能秃头的栋栋
这个作者很懒,什么都没留下…
展开
-
查询生产三种不同型号的PC的厂商
涉及到的表:pc、productselect makerfrom ( select maker,model from product where model in ( select model from pc ))as a group by maker having count(maker)=3原创 2020-05-25 19:14:08 · 3748 阅读 · 0 评论 -
查询厂商D生产的PC和便携式电脑的平均价格
设计到的表:product、pc、laptopselect avg(price) as avg_pricefrom ( select model,price from pc union select model,price from laptop)as a where model in ( select model from product where maker='D')原创 2020-05-25 19:11:38 · 2140 阅读 · 0 评论 -
查询只卖三种不同型号PC的厂商
涉及到的表:这个系列的四个表均涉及到了!!!select makerfrom ( select maker,model from product where model in ( select model from pc )) as agroup by makerhaving count(maker)>=3 and maker not in ( select maker from product wher原创 2020-05-25 19:08:39 · 1319 阅读 · 0 评论 -
查询至少生产三种不同速度PC的厂商
涉及到的表:product、pcselect maker from( select a.maker,b.speed from product a join pc b on a.model=b.model group by b.speed,a.maker )as a group by maker having count(*)>=3这个涉及到了join on的用法,目前这种方法我还不太熟练...原创 2020-05-25 19:06:35 · 2132 阅读 · 0 评论 -
查询生产最高速度的计算机(PC或便携式电脑)厂商
涉及到的表:product、pc、laptopselect makerfrom productwhere model in ( select a.model model from( select model,speed from pc union select model,speed from laptop )as a where a.speed=( select m原创 2020-05-25 19:01:31 · 2488 阅读 · 0 评论 -
查询至少生产两种不同的计算机(PC或便携式电脑)且机器速度至少为133的厂商
涉及到的表:product、pc、laptopselect makerfrom ( select maker,model from product where model in ( select model from pc where speed>=133 ) union select maker,model from product where model in ( s原创 2020-05-25 18:54:23 · 1700 阅读 · 0 评论 -
查询在具有最小内存容量的所有PC中具有最快处理器的PC制造商
涉及到的表:product(找制造商maker)、pcselect makerfrom product,pc where product.model=pc.model and ram in( select min(ram) from pc )and speed in ( select max(speed) from product,pc where product.model=pc.model and ram in( selec原创 2020-05-25 18:47:29 · 932 阅读 · 1 评论 -
查询具有最低价格的的彩色打印机的制造商
涉及到的表:product、printerselect maker from product,printerwhere product.model=printer.model and color='1' and price in ( select min(price) from product,printer where product.model=printer.model and color='1')解题思路:先将两个表做连接,找出彩色打印机,再查找价格原创 2020-05-25 18:41:31 · 4357 阅读 · 1 评论 -
查询具有最高价格的机器的型号,机器包括PC、Laptop、Printer
本题关键:将三个表进行连接,查询出价格最高的机器的型号解题思路:先将三个表的型号做连接,再将三个表的价格做连接,再利用max函数取出价格最大值,与型号做连接,即找出了价格最高的机器的型号select a.model model from ( select price,model from pc union select price,model from laptop union select price,model fro原创 2020-05-25 18:34:39 · 2319 阅读 · 0 评论 -
【数据库查询--计算机、电脑系列】-- 查询速度低于任何PC的便携式电脑。
分析:涉及到pc表、laptop表利用到了**<all**的方法上代码:select model from laptopwhere speed < all ( select speed from pc)原创 2020-04-24 12:12:02 · 1513 阅读 · 0 评论 -
【数据库查询--计算机、电脑系列】--查询价格最高的打印机型号。
分析:涉及到printer这个表注意**>=all 的用法**在查找最大值时很有用上代码:select distinct modelfrom printer where price >= all ( select price from printer)...原创 2020-04-24 12:09:45 · 2800 阅读 · 0 评论 -
【数据库查询--计算机、电脑系列】--查询拥有相同速度和内存的PC机的成对的型号,输出结果属性名分别为model1,model2。
分析:只涉及到pc表,但涉及到自身连接查询,将自身表变成两个临时表上代码:select a.model as model1,b.model as model2from pc as a,pc as bwhere a.speed=b.speed and a.ram=b.ram and a.model<b.modelorder by model1;a.model<b.model...原创 2020-04-24 12:05:48 · 3570 阅读 · 1 评论 -
【数据库查询--计算机、电脑系列】--查询在两种或两种以上PC机上出现的硬盘容量。
分析:只涉及到了pc表这道题主要注意count的使用表结构见之前的博文上代码:select hdfrom pcgroup by hdhaving count(*)>=2;原创 2020-04-24 12:01:58 · 2514 阅读 · 0 评论 -
【数据库查询--计算机、电脑系列】--查询所有出售便携式电脑(而不出售PC机)的生产厂商。
分析:涉及到三个表:product、laptop、pc表表结构详见:点这里涉及到嵌套查询、连接查询上代码:select distinct makerfrom product,laptopwhere product.model=laptop.model and maker not in ( select maker from product,pc where pr...原创 2020-04-24 11:59:53 · 2559 阅读 · 0 评论 -
【数据库查询--计算机、电脑系列】--查询由生产厂商B生产的所有产品的型号(model) 和价格(price)。
分析:这道题将四个表全部涉及到了,所以这时应想到一个方法:union的使用提示:查询按照pc、laptop和printer的顺序进行。上代码:select model,pricefrom ( select model,price from pc union select model,price from laptop union se...原创 2020-04-24 11:54:32 · 1971 阅读 · 0 评论 -
【数据库查询--计算机、电脑系列】--涉及到的表样例、结构
laptop表PC表product表printer表原创 2020-04-21 21:09:45 · 386 阅读 · 0 评论 -
【数据库查询--计算机、电脑系列】--查询配置了容量至少为1G字节硬盘的便携式电脑的生产厂商及其速度。
分析:涉及到的表:product、laptop表表结构详见点这里话不多说,上代码select maker,speedfrom product,laptopwhere type='便携式电脑' and hd>=1 and product.model=laptop.model;简单的连接查询...原创 2020-04-24 11:43:06 · 2071 阅读 · 1 评论