Hi
I have 4 tables containing records that are all associated and I need to delete data from all the tables as follows :
delete photographer using his id
delete all productions associated with that photographer
delete all images associated with those productions
delete all sales associated with those images
I figured that the correct sql would be :
$sql = "DELETE photo, production, image, sales FROM photo AS t1
LEFT JOIN production AS t2.WHERE t2.fo_id=t1.fo_id
LEFT JOIN image AS t3 WHERE t3.prod_id=t2.prod_id
LEFT JOIN sales AS t4 WHERE t4.image_id=t3.image_id
WHERE t1.fo_id='".$fo_id."'";
but I have two questions :
should I be using INNER JOIN or RIGHT JOIN instead of LEFT JOIN ?
is there any way of doing a sort of simulated delete where I can output all the records that would be deleted (without actually deleting them) so that I can check that my sql is only going to delete the right data ?
I suppose that would be too good to be true, but you never know !!
thanks for any help or advice you may have on this