[SQL]中使用联接
DECLARE @a table(i int)
DECLARE @b table(i int)
INSERT INTO @a SELECT 1 UNION ALL SELECT 2
INSERT INTO @b SELECT 1 UNION ALL SELECT 3
SELECT a.i,b.i FROM @a AS a INNER JOIN @b AS b ON a.i =b.i
SELECT a.i,b.i FROM @a AS a LEFT JOIN @b AS b ON a.i =b.i
SELECT a.i,b.i FROM @a AS a RIGHT JOIN @b AS b ON a.i =b.i
SELECT a.i,b.i FROM @a AS a FULL JOIN @b AS b ON a.i =b.i
DECLARE @b table(i int)
INSERT INTO @a SELECT 1 UNION ALL SELECT 2
INSERT INTO @b SELECT 1 UNION ALL SELECT 3
SELECT a.i,b.i FROM @a AS a INNER JOIN @b AS b ON a.i =b.i
SELECT a.i,b.i FROM @a AS a LEFT JOIN @b AS b ON a.i =b.i
SELECT a.i,b.i FROM @a AS a RIGHT JOIN @b AS b ON a.i =b.i
SELECT a.i,b.i FROM @a AS a FULL JOIN @b AS b ON a.i =b.i
posted on 2005-02-25 14:32 Goodspeed 阅读(4879) 评论(0) 编辑 收藏 举报