Delete duplicate rows in MySQL Workbench [duplicate]
I'm trying to remove some duplicate values that appear in the Nashville Housing Data for Data Cleaning dataset but my query doesn't work. I am using MySQL Workbench and this is the error I am getting.
Error Code: 1093. You can't specify target table 'Tb1' for update in FROM clause
Can someone explain to me how I can solve it?
DELETE FROM PortafolioProject.NashvilleHousing AS Tb1
WHERE EXISTS (SELECT 1 FROM PortafolioProject.NashvilleHousing AS Tb2
WHERE Tb2.ParcelID = Tb1.ParcelID AND
Tb2.PropertyAddress = Tb1.PropertyAddress AND
Tb2.SalePrice = Tb1.SalePrice AND
Tb2.SaleDate = Tb1.SaleDate AND
Tb2.LegalReference = Tb1.LegalReference AND
Tb2.UniqueID < Tb1.UniqueID);
精彩评论