最高月份Mysql / PHP

Here is my sql table

| id | data      | date           |
|----|-----------|----------------|
| 1  | some data | october 2014   |
| 2  | some data | september 2014 |

and I want to fetch the latest month year in the table since date is varchar how do I get the max date out ?

This should do it:

SELECT max(str_to_date(date, '%M %Y')) as max_date 
FROM schema.data;

Here's a fully tested PHP example:

<?php

    function getMaxDate() {
        try {       
            $db = new PDO("mysql:host=localhost;charset=utf8", "root", "root");
            $cmd = $db->prepare("
                SELECT max(str_to_date(date, '%M %Y')) as max_date 
                FROM schema.data;
            ");
            $cmd->execute();
            $result = $cmd->fetch();
            return $result[0];
        } catch (PDOException $e) { echo $e->getMessage(); return; }
    }

    echo getMaxDate();

?>

Returns the following:

2014-10-00