In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Union is a union operation on the result set, which requires that the two collections have the same fields and types.
Union: joins two result sets, excluding duplicate rows, and sorts the default rules
Union all: joins two result sets, including duplicate rows, without sorting
Union: we did two queries on the same table, and no duplicate 2 items appeared in the query results:
Select user_no, dept_code, sales_amt
From t_sales
Union
Select user_no, dept_code, sales_amt
From t_sales
Which statement is sorted by default rule? Is sorted in ascending order in the order in which we query the fields. The above is sorted by user_no,dept_code,sales_amt. To prove what we said, we change the order of the query fields and query by sales_amt,user_no,dept_code:
Select sales_amt, user_no, dept_code
From t_sales
Union
Select sales_amt, user_no, dept_code
From t_sales
The results are clearly sorted in ascending order in what we call the query fields.
Union all: merge the collections of 2 queries without dealing with duplicate rows:
Select user_no, dept_code, sales_amt
From t_sales
Union all
Select user_no, dept_code, sales_amt
From t_sales
We queried the table twice, so there were two records for each record. And the resulting dataset is out of order. In fact, this is our superficial phenomenon, and there is also an order in the returned result set: first return the results of the first query, the order of return is in the order of record insertion, and then return the result set of the second query. The order of return is also in the order of record insertion. This can be verified by the following two scripts:
Select user_no, dept_code, sales_amt
From t_sales a
Where a.sales_amt 3000
The first query returns three blue records.
Select user_no, dept_code, sales_amt
From t_sales a
Where a.sales_amt > 3000
Union all
Select user_no, dept_code, sales_amt
From t_sales a
Where a.sales_amt
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.