标签:select nvarchar varchar table left join creat ima union all arc
--DROP TABLE dbo.TableA;
--DROP TABLE dbo.TableB;
--CREATE TABLE TableA
--(
-- id INT PRIMARY KEY IDENTITY(1,1),
-- nm nvarchar(20)
--);
--CREATE TABLE TableB
--(
-- id INT PRIMARY KEY IDENTITY(1,1),
-- job int,
-- aid INT
--);
SELECT * FROM dbo.TableA;
SELECT * FROM dbo.TableB;
--INNER JOIN
SELECT dbo.TableA.*, dbo.TableB.* FROM dbo.TableA INNER JOIN dbo.TableB on dbo.TableA.id = dbo.TableB.aid;
--LEFT join
SELECT dbo.TableA.*, dbo.TableB.* FROM dbo.TableA LEFT JOIN dbo.TableB ON TableA.id = TableB.id;
--RIGHT JOIN
SELECT dbo.TableA.*, dbo.TableB.* FROM dbo.TableA Right JOIN dbo.TableB ON TableA.id = TableB.aid;
--FULL JOIN
SELECT dbo.TableA.*, dbo.TableB.* FROM dbo.TableA FULL JOIN dbo.TableB ON TableB.aid = TableA.id;
--UNION
SELECT dbo.TableA.id FROM dbo.TableA UNION SELECT dbo.TableB.aid FROM dbo.TableB
--UNION ALL
SELECT dbo.TableA.id FROM dbo.TableA UNION all SELECT dbo.TableB.aid FROM dbo.TableB
标签:select nvarchar varchar table left join creat ima union all arc
原文地址:http://www.cnblogs.com/knightluffy/p/6715757.html