SQL语句select好象可以嵌套,怎么用法?

easygoals 2003-08-22 10:34:10
SQL语句select好象可以嵌套,也就是将将另一个select作为一个select的输入?
...全文
504 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tiexinliu 2003-08-23
  • 打赏
  • 举报
回复
一个例子:
select * from customer where Region_name in (select name from region where province='河北')
michaelpeng7799 2003-08-22
  • 打赏
  • 举报
回复
最好粘到查询分析器里看
michaelpeng7799 2003-08-22
  • 打赏
  • 举报
回复
Select di.BillNumberID,di.BillDate,di.BillCode,bs.Btypeid1,bs.PtypeID from
-- 已销售序列号即已销售商品
(select B.Serial,B.PtypeID,s.BillNumberID,B.btypeid1,S.Billtype from
(select * from gp_inoutptypeserial where OutKtyeID<>'') as S -- S 出库的商品
inner join
(select * from gp_inoutptypeserial where OutktyeID=''/*billtype=34*/) as B -- B 包括了所有商品(也不包括销退的序列号)
on S.Serial=B.Serial
where B.ifcheck='t' and S.billtype='11' and B.billtype<>'45' and B.btypeID1=@szBtypeID and B.Ptypeid=@szPtypeID) as BS
Inner Join
----销售开单中商品的数量以及单据信息
(select i.BillNumberID,i.BillDate,i.BillCode from
(select BillnumberID from salebill where Ptypeid=@szPtypeID group by BillnumberID) as d
inner join
(select BillNumberID,BillDate,BillCode from billindex where BillDate between @szStartDate and @szEndDate and ifcheck='t') as i
on d.BillNumberID=i.BillNumberID) as DI
On di.BillNumberID=bs.BillNumberID where bs.Serial not in
(select g.serial from gp_inoutptypeserial as g --not in 过滤已销售出但又销退的序列号商品
inner join billindex as b on g.billnumberid=b.billnumberid
where g.ptypeid=@szPtypeID and g.billtype='45' and g.IfCheck='t' and b.ifCheck='t')
Order by di.BillNumberID
madyak 2003-08-22
  • 打赏
  • 举报
回复
Select * from (select * from A) B
是不是指这种用法(Ms SqlServer中的用法)

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧