Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am new to databases and working with MySQL. I have a large MySQL table with the following columns: Id, Link, Timestamp.

And I have a list of links. I want to keep only the rows with link column that matches an entry in this list.

Any pointers to how I accomplish this?

share|improve this question
    
How long is that list compared to the number of rows in your table? Is this something you want to do once, or regularly? –  Mat May 2 '13 at 5:05
    
are you looking for a DELETE statement? –  Tobias Zander May 2 '13 at 7:33
add comment

1 Answer

DELETE FROM MyBigUberTable WHERE Link NOT IN (...);

That should do it. Just replace the ellipsis with a comma-separated list of of Link values (or a SELECT statement that produces said list).

share|improve this answer
    
This will do it, but fair warning that this will be very slow depending on what OP's definition of 'large' is. –  Derek Downey May 2 '13 at 13:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.