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

时间:2016-07-22 06:19:23

标签: mysql sql database sql-delete rowdeleting

我正在大学开展一个小项目。我遇到了一个问题,我想删除特定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%'

但失败了。 请帮助我,并提前感谢。

5 个答案:

答案 0 :(得分:3)

*查询中删除DELETE

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'

答案 1 :(得分:3)

*删除query statement,它应该如下所示

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'

答案 2 :(得分:2)

从DELETE查询中删除*,即可。

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'

答案 3 :(得分:0)

我相信你想在单个查询中删除所有表中的记录。然后查询将是:

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

答案 4 :(得分:0)

从查询中删除*

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'