mysqlsqlselectsql-order-bymax

How to get Max of ID without use of MAX()


I want to get the maximum id from table with ought use of any function like max or else.I need simple pure query.Any one help me to solve this problem . We simply write

select max(id) from table

but i don't want to use max()


Solution

  • Use ORDER BY and LIMIT

    SELECT id
    FROM table
    ORDER BY id DESC
    LIMIT 1