0

I know that this is not the perfect question for SO but this question is very important for me:

DELETE FROM `pligg_links` WHERE `link_id` > 10000

Will this query delete all entries in table pligg_links which have link_id's bigger than 10000?

3
  • 3
    Have you tried to run this line to see what happens? Commented May 18, 2012 at 20:09
  • no because it needs to do exactly as indicated above other wise ... Commented May 18, 2012 at 20:10
  • 4
    @Chriswede Are you trying to test above query on production directly? Commented May 18, 2012 at 20:10

4 Answers 4

2

If you're not sure then run a SELECT first to see what will be deleted:

SELECT * FROM `pligg_links` WHERE `link_id` > 10000

The rows that are returned by this query are those that will be deleted by changing SELECT * to DELETE.

I would recommend using this technique any time you are writing a DELETE statement to prevent accidents due to typos, and especially so if recovering accidentally deleted data is time consuming.

Sign up to request clarification or add additional context in comments.

Comments

1

Assuming you got the propper rights, it will.

1 Comment

It will also fire any ON DELETE CASCADE foreign keys and delete triggers that might be defined.
1

If link_id is, indeed, an numerical field, then yes.

Comments

1

Always try destructive statements on a backup copy of the database before using it on production. That's assuming you have a copy of the database somewhere.

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.