我在SQL Server中有两个这样的SELECT语句:
(SELECT [UserID] FROM [User]) (SELECT [TailUser], [Weight] FROM [Edge] WHERE [HeadUser] = 5043)
我想在[UserID]属性和[TailUser]属性的这两个SELECT语句之间执行LEFT JOIN。我想将第二个查询中的现有记录与第一个查询中的对应记录和不存在的记录的NULL值连接起来。我怎样才能做到这一点?
SELECT * FROM (SELECT [UserID] FROM [User]) a LEFT JOIN (SELECT [TailUser], [Weight] FROM [Edge] WHERE [HeadUser] = 5043) b ON a.UserId = b.TailUser