How can I select the row with the highest ID in MySQL?

后端 未结 9 2085
故里飘歌
故里飘歌 2020-12-24 11:06

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 som

9条回答
  •  盖世英雄少女心
    2020-12-24 11:11

    Suppose you have mulitple record for same date or leave_type but different id and you want the maximum no of id for same date or leave_type as i also sucked with this issue, so Yes you can do it with the following query:

    select * from tabel_name where employee_no='123' and id=(
       select max(id) from table_name where employee_no='123' and leave_type='5'
    )
    

提交回复
热议问题