2016-07-22 276 views
0

我正在研究大學的一個小項目。我遇到了一個問題,我想從特定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%' 

但是失敗了。 請提前幫助我,謝謝。

回答

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

DELETE查詢中刪除*

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

query statement刪除*,它應該是如下

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

只需使用DELETE查詢中刪除*,這將做。

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

刪除*從查詢

DELETE FROM Signup WHERE UserName LIKE '%User_etc%'