Manipulating posts directly in database is rarely good idea, since it skips all the APIs, hooks and so on that normally participate in the process.
You should use get_posts()
to retrieve the list and wp_delete_post()
for deletion to ensure it is done properly and there are no leftovers.