Question

Firstly, I'm new to SQL - not so new to Java anymore.

Secondly, I'm using NetBeans 7.2.1 with JavaDB and when I'm trying to run a SQL query, such as:

SELECT * FROM mydatabase ORDER BY colname DESC LIMIT 0,1

and try to execute the commend, the console displays an error, namely:

Error code -1, SQL state 42X01: Syntax error: Encountered "limit" at line 1, column 55.

Any ideas on what I can do? Do you see something wrong with my query code?

Was it helpful?

Solution

Please consult the Derby FAQ at http://db.apache.org/derby/faq.html#limit

OTHER TIPS

You can easily do it like this.

SELECT * 
FROM mydatabase 
ORDER BY colname DESC 
FETCH FIRST 10 ROWS ONLY;

Reference

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top