Documentation Home
MySQL 5.6 リファレンスマニュアル
Download this Manual
PDF (US Ltr) - 26.8Mb
PDF (A4) - 26.9Mb
HTML Download (TGZ) - 7.1Mb
HTML Download (Zip) - 7.2Mb


3.6.1 カラムの最大値

もっとも大きい品番は?

SELECT MAX(article) AS article FROM shop;

+---------+
| article |
+---------+
|       4 |
+---------+

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
  Posted by Kobus Myburgh on November 5, 2013
I can not find anything confirming this, but my tests indicate that if you use MAX() on a field with an alpha-numeric value (such as ETA-000001), it does calculate the MAX() correctly, providing the number is padded by 0's.

To get a better (and probably more syntactically correct) result, you could use the following:

MAX(SUBSTRING(reference_number FROM 5 FOR 6))

for the example number given above.
Sign Up Login You must be logged in to post a comment.