0% found this document useful (0 votes)
19 views2 pages

Nested CTE With Full Join

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Nested CTE With Full Join

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

--Full Join

SELECT t1.UserID, t2.UserID, t2.TypeID, t2.Remark, UserID = ISNULL(t1.UserID, t2.UserID), t2. Name

FROM [dbo].[t1] t1

FULL JOIN [dbo].[t2] t2

ON t1.UserID = t2.UserID;

OR

SELECT UserID = ISNULL(t1.UserID, t2.UserID), t2.TypeID, t2.Remark, t2. Name

FROM [dbo].[t1] t1

FULL JOIN [dbo].[t2] t2

ON t1.UserID = t2.UserID;

-- Left Join

SELECT t1.UserID, t2.UserID, t2.TypeID, t2.Remark, UserID = ISNULL(t1.UserID, t2.UserID), t2. Name

FROM [dbo].[t1] t1

LEFT JOIN [dbo].[t2] t2

ON t1.UserID = t2.UserID;

;with cmp (UserID) --cte 1

as

(select UserID from tUserInfo

Where UserID not in (Select UserID from tRoleUsers)),

up as --cte 2

(select cmp.UserID as UserID from [dbo].[tCourseInstructor_temp] t1

inner join cmp

on t1.UserID = cmp.UserID)
--where t1.UserID IS NULL)

Select * from up

insert into [dbo].[tRoleUsers]

([UserID])

Select * from up

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy