从数据库中删除用户的所有记录

Delete All Record of a User From Database

我正在 university.I 做一个小项目,遇到一个问题,我想从特定 User 的数据库中删除所有记录。

我正在使用查询从数据库中获取所有记录。

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%'

但是无法删除那个user's记录。

我试过了:

DELETE * FROM Signup WHERE UserName LIKE '%User_etc%'

但是失败了。 请帮助我并提前致谢。

从您的 DELETE 查询中删除 *

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'

query statement中删除*,它应该如下

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'

只需从您的 DELETE 查询中删除 * 即可。

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'

我相信您想从单个查询中的所有表中删除记录。然后查询将是这样的:

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%';

从您的查询中删除 *

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'