Forum Moderators: coopster
Now I want select data from row 10 to row 30..how can i do it? i can't coded as "SELECT * FROM A WHERE id BETWEEN 10 and 30" bcos that might be some row have been deleted in the interval...
i tried code as "SELECT * FROM A LIMIT 9,20", it can work at all...
any idea?
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must be integer constants. With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
mysql> SELECT * FROM table LIMIT 5,10; # Retrieve rows 6-15
review:
[dev.mysql.com...]
LIMITclause is MySQL-specific so it makes it impossible to do the equivalent query on another database as-is. However, it is possible to write the query using that database's version of
LIMIT(e.g. MS-SQL's
TOP, Oracle's
ROWNUM). I believe PostgreSQL is the only other database implementing
LIMIT, but their syntax is actually slightly different than MySQL due to some technical misunderstandings when they attempted to implement the feature as copied from the MySQL syntax.
Can you get the query to work in the MySQL client? That's the first step - find out whether it's the PHP or the SQL part that's failing. If the query works fine on the MySQL command line (or via phpMyAdmin or mysql-front), then you perhaps are not connecting correctly to the DB server. If it has problems, debug it from the mysql command line.
Cheers,
Tom
<edit>Addition
Did you run a query in PHPmyAdmin?
what I mean is copy and paste in PHPmyAdmin (query) the query section of your PHP code and see if any error is coming up
Ususaly it will read "SQL syntax error" indeed if any error exists!
</edit>