⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1、嵌套子查询.sql

📁 本代码简单明了
💻 SQL
字号:
--嵌套子查询


简单子查询的的例子
select (select 3) from jobs


功能实现:查找包含从伦敦供应的产品的订单价格明细信息
	从[伦敦]供应的[产品]的[订单价格明细信息]


入手点-->伦敦


第一步:找伦敦的供应商
第二步:查出产品编号
第三步:获得产品的明细信息


计算机实现:
第一步:
select supplierid from suppliers 
where city='London'

select productid from products 
where supplierid = 

select * from [order details]
where productid in 




然后组合

USE nothwind
GO
select * from [order details]
where productid 
in
(select productid from products 
where supplierid=
(select supplierid from suppliers 
where city='London')
)















--测试

--功能:查找员工Robert.King的客户的全部信息


select * from employees










--三个步骤:

select employeeID from employees 
where firstname = 'Robert' and lastname = 'King'

select customerid from orders where employeeid = 7 

select * from customers 
where customerid in ()



--整合
select * from customers 
where customerid in 
(
    select customerid from orders 
    where employeeid = 
    (
	select employeeID from employees 
	where firstname = 'Robert' and lastname = 'King'
    )
)


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -