I have three tables one of this storing users basic information, the other one is profile information and the last one is storing user picture.
When i deleting these user i need to delete all of the data in these tables. So i write a query like this.
DELETE Kullanicilar FROM Kullanicilar
INNER JOIN ProfilBilgileri ON Kullanicilar.ID = ProfilBilgileri.UyeID
INNER JOIN UyeResim ON Kullanicilar.ID = UyeResim.UyeID
WHERE Kullanicilar.ID=@ID
But it just deleting the data from "Kullanicilar" table.
Any suggestions?
EDIT : I'm using MSSQL 2008 but hosting firm 2000 so i need compatible code.
You can use a trigger like Xavinou sugested or, if you have foreign keys in your tables, you can go with Delete on Cascade option. Your foreign keys will be created using this:
FOREIGN KEY ([Id]) REFERENCES AnotherTable
ON DELETE CASCADE