我有一个SELECT查询:Mysql的转换SELECT查询,删除查询
SELECT Data.VendorProductRateID
FROM
(SELECT MIN(VendorProductRateID) VendorProductRateID
FROM TMP_VendorProductRate
WHERE VendorProductID = 4
AND VendorProductRateTxnInfoID = 89
GROUP BY DialCode,StartTime) Data,
TMP_VendorProductRate TMP_VendorProductRate
WHERE (TMP_VendorProductRate.VendorProductRateID = Data.VendorProductRateID);
结果:
VendorProductRateID
123
124
125
我的表有50条记录所以现在我想删除所有记录不大于3的ID。
我有试过下面的查询,但没有得到我的回答:
DELETE FROM `TMP_VendorProductRate` AS CHC WHERE CHC.VendorProductRateID NOT IN
(
SELECT Data.VendorProductRateID
FROM
(SELECT MIN(VPR.VendorProductRateID) VendorProductRateID
FROM TMP_VendorProductRate VPR
WHERE VPR.VendorProductID = 4
AND VPR.VendorProductRateTxnInfoID = 90
GROUP BY VPR.DialCode,VPR.StartTime
)
Data,
TMP_VendorProductRate TMP_VendorProductRate
WHERE (TMP_VendorProductRate.VendorProductRateID = Data.VendorProductRateID)
)
错误:#1064 - 你在你的SQL语法错误;检查对应于你的MySQL服务器版本使用附近的“AS CHC WHERE CHC.VendorProductRateID NOT IN ( SELECT Data.VendorProductRa”在行1
请帮我正确的语法手册。
任何错误到来或什么? – KMS
DELETE查询中有错误。 –
也分享那个错误.. – KMS