so I got a blog page, where useres can post "articles" and in these articles there is the possibility to write comments. I want to create a IF Query in PHP to delete the article, if only a article is there and no comment or if there is a comment delete the article and the comment in the database.
$sql = "DELETE beitrag , kommentar
FROM beitrag
INNER JOIN kommentar
WHERE beitrag.beitrag_id= kommentar.beitrag_id
and beitrag.beitrag_id=$pid";
Currently this is how my DELTE is looking. It only deletes, if there is article and a comment.