关联查询,两表关联逗号隔开查询

 

 

CREATE TABLE #t1 ( i INT , k INT )

CREATE TABLE #t2 (    i INT ,    k INT )

INSERT INTO #t1 ( i, k )VALUES  ( 0 , 0   )
INSERT INTO #t1 ( i, k )VALUES  ( 1 , 1   )
INSERT INTO #t1 ( i, k )VALUES  ( 1 , 0   )

INSERT INTO #t2 ( i, k )VALUES  ( 0 , 0   )
INSERT INTO #t2 ( i, k )VALUES  ( 1 , 0   ) 

SELECT 
    t1.*,t2.* 
FROM #t1 t1 ,#t2 t2 WHERE t1.i=t2.i AND t1.k = t2.k


SELECT 
    t1.*,t2.* 
FROM #t1 t1 ,#t2 t2 WHERE t1.i=t2.i

 

 

 

posted @ 2022-03-08 17:16  蓝雨冰城  阅读(269)  评论(0编辑  收藏  举报