Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql retrieve all rows with limit

Tags:

sql

mysql

I want to retrieve all rows of a particular user with limit 0,x..

So i just want to ask is there any way to retrieve all rows in mysql without calling a method which returns count(id) of x& without making an overload of existing function which does not have limit at all in query & withour string.Relace() functionality.

As internally mysql is might using this when we check show all check Box then all rows of taht table are displayed

like image 785
d k Avatar asked Feb 19 '10 08:02

d k


People also ask

How do I limit the number of rows in MySQL query?

In MySQL the LIMIT clause is used with the SELECT statement to restrict the number of rows in the result set. The Limit Clause accepts one or two arguments which are offset and count. The value of both the parameters can be zero or positive integers.

How will you limit a MySQL query to display only top 10 rows?

To select first 10 elements from a database using SQL ORDER BY clause with LIMIT 10. Insert some records in the table using insert command. Display all records from the table using select statement.

How do I limit the number of rows returned?

You use the LIMIT clause to constrain the number of rows returned by the query. For example, a SELECT statement may return one million rows. However, if you just need the first 10 rows in the result set, you can add the LIMIT clause to the SELECT statement to retrieve 10 rows.

Does limit work in MySQL?

MySQL provides a LIMIT clause that is used to specify the number of records to return. The LIMIT clause makes it easy to code multi page results or pagination with SQL, and is very useful on large tables. Returning a large number of records can impact on performance.


2 Answers

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

SELECT * FROM tbl LIMIT 95,18446744073709551615;

This can be found in mysql developers documentation. http://dev.mysql.com/doc/refman/5.0/en/select.html

like image 192
Vars Avatar answered Sep 24 '22 22:09

Vars


Simple solution is sending int's max range to method i.e 2147483647 as it is same in both mysql & c# (4 bytes) can use int.MaxValue .

see references:

  1. http://dev.mysql.com/doc/refman/4.1/en/numeric-types.html
  2. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types.
like image 34
3 revs, 3 users 62% Avatar answered Sep 24 '22 22:09

3 revs, 3 users 62%