Rechercher dans le manuel MySQL
3.6 Examples of Common Queries
[+/-]
- 3.6.1 The Maximum Value for a Column
- 3.6.2 The Row Holding the Maximum of a Certain Column
- 3.6.3 Maximum of Column per Group
- 3.6.4 The Rows Holding the Group-wise Maximum of a Certain Column
- 3.6.5 Using User-Defined Variables
- 3.6.6 Using Foreign Keys
- 3.6.7 Searching on Two Keys
- 3.6.8 Calculating Visits Per Day
- 3.6.9 Using AUTO_INCREMENT
Here are examples of how to solve some common problems with MySQL.
Some of the examples use the table shop
to hold
the price of each article (item number) for certain traders
(dealers). Supposing that each trader has a single fixed price per
article, then (article
,
dealer
) is a primary key for the records.
Start the command-line tool mysql and select a database:
shell> mysql your-database-name
To create and populate the example table, use these statements:
- (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),
- (3,'C',1.69),(3,'D',1.25),(4,'D',19.95);
After issuing the statements, the table should have the following contents:
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-examples.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.