Hello, $query="SELECT * FROM products WHERE cat1='$cat1' AND cat2='$cat2' Limit 20 OFFSET 3"; this query when executed gives following error 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 ' OFFSET 3' at line 1 can anyone help with it?
Hi, From what i found on the net: Instead of the OFFSET keyword you can use 2 parameters in LIMIT: $query="SELECT * FROM products WHERE cat1='$cat1' AND cat2='$cat2' Limit 20,3"; Code (markup):
The offset argument is the first one, so, the correct query is like limit 3, 20 ( it will return the next 20 rows starting from the 4 )
limit - not really good with very big data sets. If you need use in future use LIMIT 100000, 50 mysql need find all 100000+50 rows and only then provide to you 50 rows. You can solve this problem another way. Use something like this - SELECT * FROM table WHERE id > previous_id LIMIT 50