求SQL语句,将多个表合成一个表,是一对多的关系
求SQL语句,将多个表合成一个表,每个表的结构不一样。要过滤重复的字段和行
如:
tb1
(
id int primary key,
name varchar(10),
title varchar(10),
)
tb2
(
id int ,
name varchar(10),
title varchar(10),
address varchar(10)
foreign key (id) references tb1(id)
)
tb3
(
id int,
name varchar(10),
tel varchar(10),
address varchar(10)
foreign key (id) references tb1(id)
)
------解决方案--------------------
SELECT DISTINCT a.ID, a.Name, a.Title, b.Address, c.Tel FROM tb1 a ,tb2 b,tb3 c
where A.ID = B.ID AND A.ID= C.ID AND B.ID=C.ID