Murad Elboudy
Murad Elboudy

Reputation: 483

How to delete a row in MySQL if the condition is met

I have rows with a column called Flags and I want to delete a certain row when the number of flags reaches 100 in that column. SELECT IF(Flags = 100, DELETE, "false") FROM posts WHERE ID = 6; This obviously didn't work.

Upvotes: 2

Views: 3458

Answers (1)

Kostas Mitsarakis
Kostas Mitsarakis

Reputation: 4747

DELETE FROM posts WHERE ID = 6 AND Flags >= 100;

Upvotes: 6

Related Questions