select * from a union all select * from b 字段个数和类型要相同是不是指这个或者你是指左、右接接吧,如下 select * from a,b where a.字段 = b.字段(+) --左连接 select * from a,b where a.字段(+) = b.字段 --右连接
select * from a.主键=b.外键;
1.两表关联查询: a.左连接:select * from a left join b on a.id=b.id; b.右连接:select * from a right join b on a.id=b.id; c.全连接:select * from a inner join b on a.id=b.id; 2.两表的对应关系是隐形的,这是我们设计数据库及表结构时候实现的。
union all
select * from b
字段个数和类型要相同是不是指这个或者你是指左、右接接吧,如下
select * from a,b where a.字段 = b.字段(+) --左连接
select * from a,b where a.字段(+) = b.字段 --右连接
a.左连接:select * from a left join b on a.id=b.id;
b.右连接:select * from a right join b on a.id=b.id;
c.全连接:select * from a inner join b on a.id=b.id;
2.两表的对应关系是隐形的,这是我们设计数据库及表结构时候实现的。