SQL_test_01_join__multy

create table gtest_t1(
g_col1 integer
,g_col2 varchar(100)
,g_col3 integer
)


create table gtest_t2(
g_col1 integer
,g_col4 varchar(100)
,g_col3 integer
)


insert into gtest_t1
values( 1, 'guyu', 1),
( 1, 'guyu1', 2),
( 2, 'conghua', 1),
( 2, 'conghua', 2)


insert into gtest_t2
values( 1, 'yingying', 1),
( 1, 'yingying1', 2),
( 2, 'bai', 1),
( 2, 'bai1', 2)


--test inner jion
select * from gtest_t1 t1
join gtest_t2 t2
on t1.g_col1 = t2.g_col1
and t1.g_col3 = t2.g_col3

                                          ----result row=4

--test inner jion multy line
select * from gtest_t1 t1
join gtest_t2 t2
on t1.g_col1 = t2.g_col1

                                          ----result row=8

drop table gtest_t1
drop table gtest_t2

posted @ 2021-11-10 19:03  小葱饼子  阅读(32)  评论(0)    收藏  举报