Question: How can I select the row with the highest ID in MySQL? This is my current code:

```
SELECT * FROM permlog WHERE max(id)

```

Errors come up, can someone help me?

Answer: 
```
SELECT * FROM permlog ORDER BY id DESC LIMIT 0, 1

```
For MySQL:

```
SELECT *
FROM permlog
ORDER BY id DESC
LIMIT 1

```

You want to sort the rows from highest to lowest `id`, hence the `ORDER BY id DESC`. Then you just want the first one so [`LIMIT 1`](http://dev.mysql.com/doc/refman/5.6/en/select.html):

> 
> The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement.  
> 
>  [...]  
> 
>  With one argument, the value specifies the number of rows to return from the beginning of the result set
> 
> 
>