Cool Sporty
Cool Sporty

Reputation: 311

Deleting random rows from a table without knowing anything about the table ids

I'm having a problem in mysql. I want to delete 20 rows from a table containing 100+ records.

I do not know the id's of the rows, any special identification of the rows to be deleted. I want to just delete the any random rows from my table.

Please help me... i am new to this condition.

Upvotes: 4

Views: 1500

Answers (1)

Zane Bien
Zane Bien

Reputation: 23125

You can do:

DELETE FROM tbl
ORDER BY RAND()
LIMIT 20

See MySQL DELETE syntax

Upvotes: 10

Related Questions