A brief Analysis of the examples of USING and HAVING usage in MySQL
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.