In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
What is the basic syntax of mysql multi-table federated query? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
Mysql multi-table federated query statement is: use select statement, union keyword, syntax is [select statement 1 union [union option] select statement 2 union [union option] select statement n].
The mysql multi-table federated query statement is:
A federated query result is to federate the query results of multiple select statements.
You can merge using the union and union all keywords.
Basic syntax:
Select statement 1
Union [union options]
Select statement 2
Union [union options]
Select statement n
The union option has two options: all (indicates repetition is also output) and distinct (de-duplicates, completely duplicates, deduplicates by default)
The fields of the two tables are the same.
Example: select id,addrid from addr union all select id,addrid from student
The significance of federated query
1. Query the same table, but the requirements are different
two。 Multi-table query: the structure of multiple tables is exactly the same, and the saved data (structure) is also the same.
The use of federated query order by
In federated queries: order by can only use the last one, and you need to use parentheses on the query statement.
Example:-(error) select * from student where sex= "man" order by scoreunionselect * from student wherre sex= "woman" order by score; this situation will report an error, because there cannot be two order by--- (correct but not required) select * from student where sex= "man" unionselect * from student wherre sex= "woman" order by score in a sentence This is true, but merging makes no sense, he will disrupt the previous sex score-(select * from student where sex= "man" order by scorelimit 10) union (select * from student wherre sex= "woman" order by scorelimit 10); use order by in the clause, because of priority, the whole clause needs to be enclosed in () and must be used in combination with limit, otherwise it will not take effect. Thank you for reading! After reading the above, do you have a general understanding of the basic syntax of mysql multi-table federated query? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.
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.