Limiting the number of rows fetched

auto stmt=conn->prepare("SELECT price FROM books order by stock_id");

stmt->limit(10);

stmt->execute();

double price;

while (stmt->fetch(0, price))
{
    // ...
}

limit() must be invoked before execute(), and it sets the upper limit on the number of rows returned by the SELECT. If the SELECT returns more rows, the additional rows get ignored. This is done using the underlying database driver's most efficient way. The default setting of 0 specifies no upper limit on the number of rows.