Examples of Common Queries You can also use scripts from the  mysql  prompt by using the  source  command or  \.  command: See Section 4.5.1.5, “Executing SQL Statements from a Text File” , for more information. 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: To create and populate the example table, use these statements: After issuing the statements, the table should have the following contents: “What is the highest item number?” Task: Find the number, dealer, and price of the most expensive article. 328 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 CREATE TABLE shop ( article INT UNSIGNED DEFAULT ’0000’ NOT NULL, dealer CHAR(20) DEFAULT ’’ NOT NULL, price DECIMAL(16,2) DEFAULT ’0.00’ NOT NULL, PRIMARY KEY(article, dealer)); INSERT INTO shop VALUES (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); SELECT * FROM shop ORDER BY article; +---------+--------+-------+ | article | dealer | price | +---------+--------+-------+ | 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 | +---------+--------+-------+ shell>  mysql  your-database-name mysql>  source  filename ; mysql>  \.  filename SELECT MAX(article) AS article FROM shop; +---------+ | article | +---------+ | 4 | +---------+