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: 
if it's just the highest ID you want. and ID is unique/auto\_increment:

```
SELECT MAX(ID) FROM tablename

```
Since both `SELECT MAX(id) FROM table` and `SELECT id FROM table ORDER BY id DESC LIMIT 0,1` fulfill the goal, the interesting part is, which performs better.

`SELECT MAX(id) FROM table`: 152ms  

`SELECT id FROM table ORDER BY id DESC LIMIT 0,1`: 25ms  

(InnoDB-table with 55M rows on MySQL 8.0, 10 runs, average result)

Of course thats not representive, but gives an idea, that the ORDER BY method performs significantly better.