sql 数据 插入 虚拟表

为红颜而拔剑 2014-10-25 02:54:32
同一张表,查出来的数据放入一张虚拟表中

select * from SysBill a,VersionModel b where a.ModelId=b.ID

select * from SysBill where ModelId is Null

求帮助,急急急急急,在线等~~~~
...全文
583 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tiger_Zhao 2014-10-28
  • 打赏
  • 举报
回复
何必分成两句,等价的查询不就是
select *
from SysBill a
where ModelId is Null
OR EXISTS (SELECT *
FROM VersionModel b
where a.ModelId=b.ID
)
卖水果的net 版主 2014-10-28
  • 打赏
  • 举报
回复
如果数据量不大的话,使用表变量吧,和临时表一样简单。
xb8315381 2014-10-28
  • 打赏
  • 举报
回复
新手用select * into #B from table 好理解些
唐诗三百首 2014-10-25
  • 打赏
  • 举报
回复
SQL Server没有虚拟表的概念, LZ可以考虑用临时表,表变量或视图.
还在加载中灬 2014-10-25
  • 打赏
  • 举报
回复

IF OBJECT_ID('#T')IS NOT NULL
DROP TABLE #T
GO
select a.* INTO #T from SysBill a,VersionModel b where a.ModelId=b.ID
 
INSERT INTO #T
select * from SysBill where ModelId is Null
还在加载中灬 2014-10-25
  • 打赏
  • 举报
回复
--只要你的内容列能对上
select * INTO #T from SysBill a,VersionModel b where a.ModelId=b.ID

INSERT INTO #T
select * from SysBill where ModelId is Null

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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