In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use Mysql database condition query statements. I hope you will gain a lot after reading this article. Let's discuss it together.
For analysts, the most common application of Mysql database is the select query statement. This article mainly introduces the query statement of Mysql database.
1. Single table query
1. Conditional query
Basic syntax: select * from + table name + where condition
1) scope query:
Eg:where field between 10 and 100
2) Fuzzy query
Eg:where field like'% is not sure'
Note:% represents multiple characters, _ underscore represents one character, ^ a represents data that begins with a, a $represents data that ends with a, and [abc] matches any character contained. (recommended: MySQL tutorial)
two。 Multi-condition query
Note: when and and or are used at the same time, and takes priority over or. If you want to give priority to the conditions with or, you can use parentheses for some conditions with or.
3. Sort
Basic syntax: order by field.
Remarks: the default is ascending order, ASC ascending order, DESC descending order.
Limit the number of records: limit
4. Aggregate function
Count (): number of statistical records
Avg (): average
Max (): maximum
Min (): minimum
Sum (): summation
5. Grouping
Basic syntax: select field 1, field 2, aggregate function from + table name + group by field 1, field 2
Note: group by and having are used together to filter grouping results.
Second, multi-table association query
1. Internal connection-- > inner join
An inner join is an equivalent connection, which can be omitted as join to obtain the records of the matching relationship between the fields in the two tables.
It can be understood as the "intersection" in the concept of set, and the associated field has records with two tables at the same time.
two。 Left connection-- > left join
Join to the left to get all the records of the main table on the left, even if there is no corresponding data in the right table.
3. Right connection-- > right join
Connect to the right to get all the records of the main table on the right, even if there is no corresponding data in the left table.
4. Connector-- > union
Union is used to concatenate the results of more than two select statements, combine the results into a result set, and delete duplicate data
Basic syntax: select field from Table 1 union [all | distinct] select Field from Table 2
Note: union means that if union distinct; is union all, the result set with duplicate data is returned; when using union, the selected display will be named after the field name of the previous table.
After reading this article, I believe you have a certain understanding of how to use Mysql database condition query statements, want to know more about it, welcome to follow the industry information channel, thank you for your reading!
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.