I am working on a small project in university.I am getting a problem that i want to delete all the record from database of a specific User
.
I am using a query to get all the record from database.
SELECT s.UserName,p.Name,p.Father_Name,s.Email,p.DOB,p.Gender,p.Nationality,p.Domicile,p.CNIC,p.Mobile,p.Address, e.SSC_OM,E.SSC_TM,E.SSC_EB,e.HSSC_OM,e.HSSC_TM,e.HSSC_EB, d.Choices_1,d.Choices_2,d.Choices_3
FROM Signup s
INNER JOIN Pers_D p ON p.UserName = s.UserName
INNER JOIN Edu_D e on e.UserName = p.UserName
INNER JOIN Dep_S d on d.UserName = e.UserName
WHERE [d].UserName LIKE '%User_etc%'
But cannot delete that user's
Record.
I have tried :
DELETE * FROM Signup WHERE UserName LIKE '%User_etc%'
But failed. Please help me and thanks in advance.
I believe you want to delete records from all the tables in single query. Then query would be something like:
DELETE s, p, e, d
FROM Signup s
JOIN Pers_D p ON p.UserName = s.UserName
JOIN Edu_D e ON e.UserName = p.UserName
JOIN Dep_S d ON d.UserName = e.UserName
WHERE d.UserName LIKE '%User_etc%';