0 votes
1 view
in SQL by (20.3k points)

How would I do something like this?

SQL SELECT row FROM table WHERE id=max(id)

1 Answer

0 votes
by (40.4k points)

You can use the subselect like this:

SELECT row 

FROM table 

WHERE id=(

    SELECT max(id) FROM table

    )

Note: If the value of max(id) is not unique, multiple rows will be returned. But, if you only want one such row then use this:

SELECT row from table ORDER BY id DESC LIMIT 1

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 12, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...