tvega Posted January 12, 2005 Share Posted January 12, 2005 I came across this error and as far as I know, I did not do anything. I find this error under the admin screen when I click on "Orders" under customers. How do I fix this. Please be thourough, I am a newbie. Thanks. Orders Order ID: Status: 1064 - 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 '-20, 20' at line 1 select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s where o.orders_status = s.orders_status_id and s.language_id = '1' and ot.class = 'ot_total' order by o.orders_id DESC limit -20, 20 [TEP STOP] Link to comment Share on other sites More sharing options...
tvega Posted January 12, 2005 Author Share Posted January 12, 2005 Anybody??? Thanks again. :) Link to comment Share on other sites More sharing options...
bbtjlgt Posted January 12, 2005 Share Posted January 12, 2005 The problem is with the limit clause of your sql statement. The following explains how to use the limit clause. **MySQL Manual | 13.1.7 SELECT Syntax** 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 For compatibility with PostgreSQL, MySQL also supports the LIMIT row_count OFFSET offset syntax. 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: mysql> SELECT * FROM table LIMIT 95,18446744073709551615; With one argument, the value specifies the number of rows to return from the beginning of the result set: mysql> SELECT * FROM table LIMIT 5; # Retrieve first 5 rows In other words, LIMIT n is equivalent to LIMIT 0,n. ***************************************** So to fix your code change the limit clause from "limit -20, 20" to "limit 0,20" or "limit 20". Link to comment Share on other sites More sharing options...
bbtjlgt Posted January 12, 2005 Share Posted January 12, 2005 Thanks to kremdela's reply on another user's topic who was having the same problem, the following is the solution to this problem. In the file catalog/admin/includes/classes/split_page_results.php just before the line: $sql_query .= " limit " . $offset . ", " . $max_rows_per_page; add if ($offset < 0) $offset = 0; Then in the file catalog/includes/classes/split_page_results.php just before the last line: $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page; add if ($offset < 0) $offset = 0; Hope this works for you. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.