guagay_wk
guagay_wk

Reputation: 28030

Retrieve all records with LIMIT in mysql

I have the following MySQL query;

SELECT records FROM users
LIMIT 1

One record will be retrieved. Suppose I want to retrieve all records but still use the keyword LIMIT. Can I do something like this?

SELECT records FROM users
LIMIT ALL

Upvotes: 2

Views: 4931

Answers (4)

Rahul Chaudhary
Rahul Chaudhary

Reputation: 21

If you want to retrieve all data then just use

select * from tbl;

Upvotes: -1

Kamal Palei
Kamal Palei

Reputation: 2012

Just use

SELECT records FROM users

Do not use LIMIT at all

Or if it is required to use LIMIT , use a very high number

SELECT records FROM users LIMIT 999999999999

Upvotes: 5

Shakeel
Shakeel

Reputation: 184

According to mysql doc you are supposed to use a very large number.
SELECT * FROM tbl LIMIT 95,18446744073709551615;
Terrible solution, if you ask me, but its from the mysql documentation http://dev.mysql.com/doc/refman/5.0/en/select.html#id4651990

Upvotes: 1

Matt
Matt

Reputation: 2869

You have to just make up a ridiculous number and limit it by that.

E.g. SELECT records FROM users LIMIT 18446744073709551615 if you really want to keep the limit clause. This is similar to using offset to infinite amount.

Upvotes: 2

Related Questions