0

I have a table single_post which looks something like below

id | for_post
0   50
1   50
2   100
3   75

How to delete every entry on which for_post value exist only once ?. Which means after executing the query, the last two entries will be removed because for_post exist only once.

I didn't try anything yet because I have no idea what to try. Thanks in advance

Rafik Bari
  • 4,867
  • 18
  • 73
  • 123

1 Answers1

0

How About Something like this:

DELETE FROM single_post
WHERE for_post IN
(SELECT for_post FROM single_post GROUP BY for_post HAVING count(for_post)=1)

Oferch
  • 71
  • 7