472,133 Members | 1,168 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

Mysql - Uses of Offset ?

147 100+
What is the purpose of OFFSET in mysql ?

Expand|Select|Wrap|Line Numbers
  1.    mysql>select * from info oFFSET 3 ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '3' at line 1
Apr 5 '10 #1
3 8207
Atli
5,058 Expert 4TB
Hey.

Also see the part about LIMIT in the Manual (12.2.8. SELECT Syntax)

Basically, the MySQL syntax to LIMIT the rows a result set will return goes:
Expand|Select|Wrap|Line Numbers
  1. SELECT ... LIMIT x, y
Where "x" is the number of rows you want returned and "y" is the offset. (Offset meaning; the number of rows to remove from the top of the list.)
For example, if you have a 100 rows in the original result set a "LIMIT 10, 20" would return rows #21 through #30. That is; 10 rows starting after #20.

For compatibility with PostgreSQL, you can optionally replace the comma in the LIMIT syntax with the OFFSET keyword.
Expand|Select|Wrap|Line Numbers
  1. SELECT ... LIMIT x OFFSET y
However, this is optional. You don't need to do this unless you plan on building PostgreSQL compatible queries.
Apr 6 '10 #3
santhanalakshmi
147 100+
hi,
I got it....thanks for your response
Apr 6 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by jimmy | last post: by
2 posts views Thread by info | last post: by
30 posts views Thread by Einstein30000 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.