Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql federated query statement how to write this

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the mysql joint query sentence how to write, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The mysql joint query statement is [query statement 1 union query statement 2], which requires the type and best consistency of each column of the query with multiple query statements. The union keyword is deduplicated by default, and duplicates can be included if union all is used.

Joint query

UNION federated merge: merges the results of multiple query statements into a single result

Syntax:

Query statement 1union query statement 2

Application scenarios:

When the result of the query comes from multiple tables, and the multiple tables are not directly connected, but the information of the query is the same.

Features:

1. The number of query columns of multiple query statements is required to be the same

2. The type of each column of a query that requires multiple query statements is best consistent.

3. The union keyword is deduplicated by default, and duplicates can be included if you use union all

Introduced case: query department number > 90 or mailbox contains employee information of a

SELECT * FROM employeesWHERE email like'% a%'or department_id > 90SELECT * FROM employeesWHERE email like'% a%'UNIONSELECT * FROM employeeswhere department_id > 90

Case study: query information about men in Chinese users and men in foreign users

Thank you for reading this article carefully. I hope the article "how to write mysql Joint query sentence" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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: 272

*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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report