Answer the question
In order to leave comments, you need to log in
How to remove records from a table?
You need to leave 100 records in the table, deleting everything else.
Sample SQL query:
delete from table where shop_id = '12' limit 100, 7000
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 check the manual that corresponds to your MySQL server version for the right syntax to use near ' 7000'
Answer the question
In order to leave comments, you need to log in
DELETE does not allow using offset in the request, one solution is to use a nested request
DELETE FROM table WHERE id IN(SELECT id FROM (SELECT * FROM table WHERE shop_id=12 LIMIT 100, 7000) table)
Here is another simple solution:
1) query for the number of records, "select count(id) from table where shop_id = '12' "
2) count how many records to delete - count_delete = count - 100
3) make a query "delete from table where shop_id = '12' limit :count_delete"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question