是否可以将左外部普通表与临时表连接起来?

编程入门 行业动态 更新时间:2024-10-28 16:24:16
本文介绍了是否可以将左外部普通表与临时表连接起来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建SQL Server查询,并具有带有记录的普通表,另一方面,具有带有记录的临时表,并且该表不为空,并且所有字段都没有冲突 加入

I create SQL server query and have normal table with records and in the other hand have a temp table with record and this table not empty and all fields doesn't have any conflict to join

是否可以加入这两个不同类型的表?

is possible to join this two different type table?

SELECT NormalTable.Entityname FROM NormalTable LEFT JOIN #Temp tmp ON tmp.joinID = NormalTable.joinID

推荐答案

是否可以加入这两个不同类型的表? (正常和临时)

is possible to join this two different type table? (normal and temporary)

是的,可以联接不同类型的表(永久表和临时表).连接这些表没有不同的语法.

Yes it is possible to join different type of table (permanent and temporary tables). There is no different syntax to join these tables.

例如

永久表:

CREATE TABLE NormalTable ([plateno] varchar(1), [JoinID] int) ; INSERT INTO NormalTable ([plateno], [JoinID]) VALUES ('A', 1), ('B', 2), ('C', 2), ('A', 3), ('B', 2), ('A', 4), ('A', 1) ;

临时表:

CREATE TABLE #Temp ([id] int, [date] date, [score] int) ; INSERT INTO #Temp ([id], [date], [score]) VALUES (1, '2013-04-13', 100), (2, '2013-04-14', 92), (3, '2013-04-15', 33) ;

加入两个表:

SELECT N.* FROM NormalTable N LEFT JOIN #Temp T ON N.JoinID = T.ID

更多推荐

是否可以将左外部普通表与临时表连接起来?

本文发布于:2023-10-26 01:29:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1528683.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!