SQL Select With Limit Statement


Limits the number of results to return

Syntax

SELECT select_columns FROM table_name LIMIT count
count:  number of results to limit the query to

Example


PreparedStatement stmt = conn.prepareStatement("select * from persons where id < ? and id > ? limit 3");
stmt.setLong(1, 100);
stmt.setLong(2, 2);
ResultSet ret = stmt.executeQuery();