def get_max_id(database, table, column, order=None):
    """
    Gets the query to determine the maximum id for a given table / column.

    :type str
    :param database: A database name
    :type str
    :param table: A table name
    :type str
    :param column: A column name
    :type str
    :param order: A column name to order on
    :rtype long
    :return The maximum id
    """

    if not order:
        order = column

    return 'SELECT `{:s}` FROM `{:s}`.`{:s}` ORDER BY `{:s}` DESC LIMIT 1'.format(column, database, table, order)