0

I want to delete all rows expect the 5 first rows.

/*example of the $count is equal to 5 */
$count=$xml->table->records->attributes();

This is my table:

xml_id  
   1
   2
   3
   4
   5
   6
   7
   8
   9
   10

The result would be like this

xml_id  
   1
   2
   3
   4
   5

The above 5 will be deleted.

1
  • 1
    Are the IDs that you want to keep always going to be 1-5? Commented Sep 16, 2013 at 0:23

1 Answer 1

2

Try this query :

DELETE
FROM Table1
WHERE xml_id  NOT IN
    (SELECT xml_id  
     FROM Table1
     LIMIT 5)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.