first of all, thank you for sharing your experience and wasting time on me. I searched within many threads, but still can't find the answer i'm looking for. Well, let's move to the question. How can i write a MySQL statement, that looks into different tables for results, if it finds a fit, it will be deleted. It's really hard to explain, so i think a better way would be to show an example.
DELETE FROM forum_threads, forum_comments, forum_categories
USING forum_categories
INNER JOIN forum_threads
INNER JOIN forum_comments
WHERE forum_categories.name = ?
AND forum_threads.category_id = forum_categories.id
AND forum_comments.thread_id = forum_categories.id
This code above works fine, but only, if three tables has an row, other case it returns that zero rows were affected.
So, i want to write a statement, which deletes rows from categories, threads and comments table, if exists even one of them. Example 1: forum_categories has an row, but forum_threads and forum_comments does not have any, so delete only from categories. Example 2: forum_categories has an row and forum_threads has multiple rows, but forum_comments does not have any, so delete from categories and from threads. Example 3: forum_categories does not have any row, but forum_threads has multiple rows and forum_comments has multiple rows, so don't do anything.
Each case forum_categories has only one row, and forum_threads and forum_comments can have from multiple to zero.
I tried using LEFT JOIN did not work or i am doing it wrong.