笔记213 inner join的问题

笔记213 inner join的问题

 1 --inner join的问题
 2 USE tempdb
 3 
 4 IF  OBJECT_ID(N'#tb1')  IS NOT NULL
 5 DROP TABLE #tb1
 6 GO
 7 IF  OBJECT_ID(N'#tb2')  IS NOT NULL
 8 DROP TABLE #tb2
 9 GO
10 
11 CREATE TABLE #tb1(a INT ,b INT)
12 CREATE TABLE #tb2(a INT ,c INT)
13 GO
14 
15 INSERT #tb1( a, b ) SELECT 1,2 ;
16 INSERT #tb2( a, c ) SELECT 1,3;
17 GO
18 
19 SELECT * FROM #tb1
20 SELECT * FROM #tb2
21 
22 SELECT t1.a ,t1.b,t2.c FROM #tb1 AS t1 INNER JOIN #tb2 AS t2 ON t1.a = t2.a

 

posted @ 2013-08-04 13:36 桦仔 阅读(...) 评论(...)  编辑 收藏