《数据库系统实训》实验报告——子查询与组合查询
子查詢
題號: 1.1
SQL語句描述:select cust_id from orders where order_num in (SELECT ORDER_NUM FROM ORDERITEMS where prod_id='tnt2');
查詢功能描述:查詢購買ID為tnt2的產品的客戶;
執行結果截圖:
聯結表
題號: 2.1
SQL語句描述:select vend_name,prod_name,prod_price
?? from vendors,products
?? where vendors.vend_id=products.vend_id
?? order by vend_name,prod_name;
查詢功能描述:查詢所有供應商名稱及產品名稱、價格,并且按供應商和產品名稱排序;
執行結果截圖:
高級聯結
題號: 3.1
SQL語句描述:select customers.cust_id,
customers.cust_name,
count(orders.order_num) as num_ord
from customers inner join orders
on customers.cust_id=orders.cust_id
group by customers.cust_id;
查詢功能描述:查詢所有顧客的訂單數量;
執行結果截圖:
組合查詢
題號: 4.1
SQL語句描述:select vend_id,prod_id,prod_price
from products
where prod_price<=5
union
select vend_id,prod_id,prod_price
from products
where vend_id in(1001,1002);
查詢功能描述:查詢供應商ID為1001,1002和價格小于等于5的供應商ID及產品名稱、價格;
執行結果截圖:
全文搜索
題號: 5.1
SQL語句描述:select note_text from productnotes where match(note_text) against('rabbit');
查詢功能描述:查詢含有rabbit的文本內容;
執行結果截圖:
總結
以上是生活随笔為你收集整理的《数据库系统实训》实验报告——子查询与组合查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PaddleOCR——Visual St
- 下一篇: 白盒测试——简单分支函数测试