Home >Database >Mysql Tutorial >union这个连接是有什么用的和INNER JOIN有什么区别

union这个连接是有什么用的和INNER JOIN有什么区别

WBOY
WBOYOriginal
2016-06-07 18:06:471148browse

union这个连接是有什么用的和INNER JOIN有什么区别

Inner join 是两张表做交连后里面条件相同的部分记录产生一个记录集,
union是产生的两个记录集(字段要一样的)并在一起,成为一个新的记录集

Select A.Field1,B.field2 from Table1 A inner join Table2 B on a.Field2=b.Field2 where ..........
Select Field1 from Table1 union Select Field2 from table2
方案二、
select a.id,a.title,b.content from 表格1 as a,表格2 as b where a.id=b.id order by a.id

rs("id")
rs("title")
rs("content") 另:
新建一个表xxx

sql="insert into xxx select P.id,P.title,M.content from picture P inner join miaoshu M on P.id=M.id"
conn.execute sql

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn