一.建表
create table test03(
name varchar2(20), --姓名
family_id int, --家庭id
address varchar2(20)); --家庭地址
二.插入数据
insert into test03 values('前田义明',100,'东京21号');
insert into test03 values('前田由美',100,'东京12号');
insert into test03 values('加藤茶',200,'东京31号');
insert into test03 values('加藤胜',200,'东京31号');
insert into test03 values('福尔摩斯',300,'东京41号');
insert into test03 values('华生',400,'东京41号');
表中数据如下:
三.测试
要求:查找出家庭id相同但是家庭地址不同的数据
方式一:
select a.name, a.family_id, a.address
from test03 a left join test03 b