How does union mine
1、 Difference 1: take the intersection of results
1, Union: merge two result sets, excluding plicate lines, which is equivalent to distinct, and sort by default rules at the same time
2, union all: Union operation is performed on two result sets, including repeated rows, that is, all results are displayed, no matter whether they are repeated or not
2. Difference 2: the operation after obtaining the results
1. Union: it will sort the obtained results
2. Union all: it will not sort the obtained results
3. Difference 3:
1. Union sees only one
select * from student2 where id & lt; 4
union
select * from student2 where id > 2 and id < 6
2, there are two results of union all with id = 3
select * from student2 where id & lt; 4
union all
select * from student2 where id > 2 and id < 6
4. Summary
union all is just a combination of query results, and it does not perform de plication and sorting operations. Without de plication, the execution efficiency of union all is higher than that of Union
where a.techername<>b.studentname and a.user_id=b.user_id
UNION
select b.user_id, b.techername from a_user a, b_user b
where a.techername<>b.studentname and a.user_id=b.user_id
{
{
char name[20];< br /> int n;< br /> union
{long a; char c; br />};< br />int main(){
struct str1 p1={" jf jf", 3,35; 39; f&35;39;};< br />...
}
to merge 3D entities, enter & quot; UNI" Back enter: select two 3D entities to merge and press enter to merge them
which means to execute the second
Union after executing a query command. The syntax of union is as follows:
[SQL statement 1]
union
[SQL statement 2]
suppose we have the following two tables,
store_ Information table
store_ Name sales date
Los Angeles $1500 jan-05-1999
San Diego $250 jan-07-1999
Los Angeles $300 jan-08-1999
Boston $700 jan-08-1999
Internet sales form date sales
jan-07-1999 $250
jan-10-1999 $535
jan-11-1999 $320
jan-12-1999 $750
and we need to find out what we need There are days when there are sales. To achieve this goal, we use the following SQL statement:
select date from store_ Information
UNION
SELECT Date FROM Internet_ Sales
results:
date
jan-05-1999
jan-07-1999
jan-08-1999
jan-10-1999
jan-11-1999
jan-12-1999
it is worth noting that if we use & quot; SELECT DISTINCT Date" Then we'll get exactly the same result
it should be noted that the number of union query fields must be consistent with that of the previous statement fields
related references
Advanced SQL injection with MySQL:
http://www.4ngel.net/article/30.htm