Reputation: 3
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.
Upvotes: 0
Views: 776
Reputation: 70
Delete * from your query
DELETE FROM Signup WHERE UserName LIKE '%User_etc%'
Upvotes: 0
Reputation: 644
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%';
Upvotes: 0
Reputation: 71
Just Remove * from your DELETE query, That will do.
DELETE FROM Signup WHERE UserName LIKE '%User_etc%'
Upvotes: 2
Reputation: 14669
remove *
from query statement
, it should be as below
DELETE FROM Signup WHERE UserName LIKE '%User_etc%'
Upvotes: 3
Reputation: 12378
Remove *
from your DELETE
query:
DELETE FROM Signup WHERE UserName LIKE '%User_etc%'
Upvotes: 3