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

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

Jun 07, 2016 pm 06:06 PM
join union

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 of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use JOIN in MySql How to use JOIN in MySql Jun 04, 2023 am 08:02 AM

The meaning of JOIN is just like the English word "join". It joins two tables and can be roughly divided into inner join, outer join, right join, left join and natural join. First create two tables, the following is used as an example CREATETABLEt_blog(idINTPRIMARYKEYAUTO_INCREMENT,titleVARCHAR(50),typeIdINT);SELECT*FROMt_blog;+----+------+--------+| id|title|typeId|+----+-------+--------+|1|aaa|1||2|bbb|2||3|ccc|3|

What is the usage principle of MySQL Join? What is the usage principle of MySQL Join? May 26, 2023 am 10:07 AM

Join type leftjoin uses the left table as the driving table and the left table as the basis of the result set. The data from the right table is connected to the result set. rightjoin uses the right table as the driving table and the right table as the basis of the result set to connect the left table. The data is added to the result set innerjoin. The result set takes the intersection of the two tables fulljoin. The result set takes the union of the two tables. MySQL does not have a fulljoin. The difference between union and unionall is that union will deduplicate the crossjoin Cartesian product. If the where condition is not used, the result set will be the product and of the two associated table rows. The difference is that when crossjoin creates the result set, it will be passed according to the on condition.

What are mysql's join query and multiple query methods? What are mysql's join query and multiple query methods? Jun 02, 2023 pm 04:29 PM

Compared with join query and multiple queries, which one is more efficient, MySQL multi-table related query or multiple single-table query? When the amount of data is not large enough, there is no problem using join, but it is usually done on the service layer. First: the computing resources of a stand-alone database are very expensive, and the database needs to serve both writing and reading at the same time, which requires CPU consumption. In order to make the database The throughput becomes higher, and the business does not care about the delay gap of hundreds of microseconds to milliseconds. The business will put more calculations into the service layer. After all, computing resources can be easily expanded horizontally, and databases are difficult, so most The business will put pure computing operations into the service layer, and use the database as a kv system with transaction capabilities. This is a heavy business.

How to use union in c language How to use union in c language Sep 27, 2023 am 11:00 AM

The use of union in C language is a special data type that allows different data types to be stored in the same memory location. The use of union can help us save memory space and facilitate conversion between different data types. When using union, you need to note that the corresponding member is valid and only one member can be accessed at the same time.

How to use JOIN in MySQL How to use JOIN in MySQL Jun 03, 2023 am 09:30 AM

Introduction A's unique + AB's public B's unique + AB's public AB's public A's unique B's unique A's unique + B's unique + AB's public A's unique + B's unique Practice creating table department tables DROPTABLEIFEXISTS`dept`;CREATETABLE`dept`(`dept_id`int(11)NOTNULLAUTO_INCREMENT,`dept_name`varchar(30)DEFAULTNULL,`dept_number`int(11)DEFAULTNULL,PRIMARYKEY(`dept_id`))ENGINE =InnoDBAUT

How to use mysql union to implement full outer join query How to use mysql union to implement full outer join query May 30, 2023 pm 06:49 PM

1. Union is not a method of multi-table connection query. It combines the query results of multiple query sentences into one result and removes duplicate data. 2. Full outer join queries the data of the left table and the right table, and then connects according to the connection conditions. Example #Use the left outer Aunion and the right outer BSELECT*FROMt_categorycLEFTOUTERJOINt_productpONc.cid=p.cnounionSELECT*FROMt_categorycRIGHTOUTERJOINt_productpONc.cid=p.cno

How to use the FULL OUTER JOIN function in MySQL to obtain the union of two tables How to use the FULL OUTER JOIN function in MySQL to obtain the union of two tables Jul 26, 2023 pm 05:45 PM

How to use the FULLOUTERJOIN function in MySQL to obtain the union of two tables. In MySQL, the FULLOUTERJOIN function is a powerful join operation that combines inner joins and outer joins. It can be used to get the union of two tables, that is, combine all the data in the two tables into a single result set. This article will introduce the usage of the FULLOUTERJOIN function and provide some sample code to help readers better understand. FULLOUTERJOIN function

How does java define the Union class to realize the coexistence of data bodies? How does java define the Union class to realize the coexistence of data bodies? May 14, 2023 pm 03:34 PM

Define the Union class to implement the coexistence of data bodies. In the C/C++ language, a union, also known as a union, is a data structure similar to a struct. A union, like a struct, can contain many data types and variables. The difference between the two is as follows: all variables in a struct "coexist", and all variables are effective at the same time. Each variable occupies Different memory spaces; in a union, each variable is "mutually exclusive", only one variable is effective at the same time, and all variables occupy the same memory space. When multiple data need to share memory or only one of multiple data needs to be taken at a time, a union can be used. in Java

See all articles