user2130530
user2130530

Reputation: 21

mysql query help to select details of the person with highest id

how to achieve this without using nested query or sub query.

    select * from table_name where id=(select avg(id) from table_name);

need some suggestion.

Upvotes: 1

Views: 62

Answers (2)

J A
J A

Reputation: 1766

How about

SELECT
        *
FROM 
        table_name
ORDER BY 
        id DESC
LIMIT 1 

Upvotes: 0

Kevin Seifert
Kevin Seifert

Reputation: 3572

select * from table_name order by id desc limit 1

Upvotes: 3

Related Questions