mysql - 如何删除已经选择的表?

标签 mysql

我已使用以下查询选择“重复表”

SELECT
    y.Entity,y.ExpenseTypeCode,y.ExpenseType,y.LOB,y.Center,y.Location,y.Amount,y.APSupplierID,y.ExpenseReportID,y.Employee,y.ReportDate,y.ExpenseDate,y.Description
    FROM dbo.TotalsByGLCenter$ y
        INNER JOIN (SELECT
                        Entity,ExpenseTypeCode,ExpenseType,LOB,Center,Location,Amount,Description,APSupplierID,ExpenseReportID,Employee,ReportDate,ExpenseDate, COUNT(*) AS CountOf
                        FROM  dbo.TotalsByGLCenter$
                        GROUP BY Entity,ExpenseTypeCode,ExpenseType,LOB,Center,Location,Amount,APSupplierID,ExpenseReportID,Employee,ReportDate,ExpenseDate,Description
                        HAVING COUNT(*)>1
                    ) dt ON y.Entity=dt.Entity and y.ExpenseTypeCode=dt.ExpenseTypeCode and y.ExpenseType=dt.ExpenseType and y.LOB=dt.LOB and y.Location=dt.Location and y.Center=dt.Center  and y.Amount=dt.Amount and y.APSupplierID=dt.APSupplierID and y.ExpenseReportID=dt.ExpenseReportID and y.Employee=dt.Employee and y.ReportDate=dt.ReportDate and y.ExpenseDate=dt.ExpenseDate and  y.Description=dt.Description

我想要删除选定的查询。如何使用删除上面的查询语句?

最佳答案

试试这个伙伴,

DELETE FROM your_table WHERE id IN ( 
Select (
your select query
) As alias 
)

关于mysql - 如何删除已经选择的表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39873135/

相关文章:

mysql - Google Search Appliance 索引 MySQL 数据库

mysql - 如何从表的列中删除特定字符

mysql - #1064 - 您的 SQL 语法错误无法更改表以创建外键

php - 在不绑定(bind)的情况下使用 PDO

php - 将 SQL 数据库中的数据显示为拓扑

php - 如何通过mysql查询获取不同时区事件的剩余天数,小时,分钟,秒数

php - 如何选择以及在何处(如果)使用 Kohana ORM?

MySQL JOIN 查询 -

php - 从 MySQL 列获取数组

php - 删除表情符号/unicode 字符