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

A brief Analysis of the examples of USING and HAVING usage in MySQL

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This paper gives an example of the usage of USING and HAVING in MySQL. Share with you for your reference, the details are as follows:

USING

For table joins given join conditions (which can be understood as shorthand), such as

SELECT * FROM table1JOIN table2 ON table1.id = table2.id

Using USING, you can write as

SELECT * FROM table1JOIN table2 USING (id)

HAVING

HAVING was introduced because WHERE cannot be used with statistical functions

For example, table order (order) has the following fields:

Id, date, price, customer

To find customers with a total order of less than 2000, you can write:

SELECT customer, SUM (price) FROM orderGROUP BY customerHAVING SUM (price) 1500

More readers who are interested in MySQL-related content can check out this site's special topics: "A Summary of MySQL Common functions", "A Collection of MySQL Log Operation skills", "MySQL transaction Operation skills Summary", "MySQL stored procedure skills Collection" and "MySQL Database Lock related skills Summary"

It is hoped that what is described in this article will be helpful to everyone's MySQL database design.

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.

Share To

Database

Wechat

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

12
Report