hello .. i have three tables so far called as
-------------------------------------------------
categories,scategories,products
-------------------------------------------------

in wich in the front end form when the user wants he can create a new CATEGORY (this will go in CATEGORIES table including auto increment id and category name)

and if he wants to create SUB CATEGORY he can create new by selecting a category first and adding a sub category name (this will go in SCATEGORIES table including auto increment id, catid and subcategory name)

and in products front page form if he wants to add a new product he can by selecting CATEGORY , SUB CATEGORY and PRODUCT NAME (this will go in PRODUCTS table include auto increment id,catid,scatid,proname)


Now i have a DELETE CATEGORY form and if he is gonna delete a particular category then i want to delete it from all three tables if this category id is there in any of the three tables.

and if there are not any records suppose in products there are not any records for the particular catid which we want to delete then also this should contunue.

but m getting an error using the below script ..

-------------------------------------------------
delete from categories,products,scategories where categories.id=61 and scategories.catid = 61 and products.catid = 61
-------------------------------------------------

suppose i m using the above query its getting this error
-------------------------------------------------
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where categories.id=61 and scategories.catid = 61 and products.catid = 61' at line 1
-------------------------------------------------

but suppose i have not added any sub category for this catid then also it should work or if i have not added any product related to this catid then also this query should work ..

i have tried using OR instead of AND in the query bcoz i might have not catid in other tables ..

but this is not working at all as m getting the above error ..

i can do something like this also
-------------------------------------------------
delete from categories where id=61
delete from scategories where id=61
delete from products where id=61
-------------------------------------------------

but this will take three queries but i want one which will check using OR and ignore if the catid is not in the other table and will remove if it finds catid in the particular table ..


can anybody suggest me or rather help me to solve this problem ..