Clean Code that Works.

SELECT TOP 1 in Derby

DataBase2009. 5. 28. 10:46

Sql Server: Select Top 1 * From MyRecs ORDER BY ID DESC
MySql: Select * From MyRecs ORDER BY ID DESC LIMIT 1

but in Derby.. how?

--
Bernt Marius Johnsen, Database Technology Group,
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway
--

He had answered question.

e.g. by calling stmt.setMaxRows(1);

but it will not give you the *last* record inserted (SQL is a set
language!). It will give you the row with the *highest* ID.

What about
select * from MyRecs where ID in (select max(ID) from MyRecs)


What is max function? go link
Original Thread is Here.