我有一个问题,这个sql,它说这是一个语法问题附近删除,但无法找到它,请帮助
这是我第一次尝试使用delete函数,所以不知道怎么做
SELECT
DE.ContactID AS ContactID,
DE.[First Name] AS [First Name],
DE.[Last Name] AS [Last Name],
DE.Email AS Email,
CASE WHEN bu.ContactId IS NULL
THEN '0'
ELSE '1'
END AS Business,
CASE WHEN des.ContactId IS NULL
THEN '0'
ELSE '1'
END AS Design,
CASE WHEN he.ContactId IS NULL
THEN '0'
ELSE '1'
END AS Health,
CASE WHEN ho.ContactId IS NULL
THEN '0'
ELSE '1'
END AS Hospitality,
DELETE
FROM [IOW Registered - All workshops]
WHERE (Business IS NULL OR Business = 0)
AND (Design IS NULL OR Design = 0)
AND (Health IS NULL OR Health = 0)
AND (Hospitality IS NULL OR Hospitality = 0)
FROM [Domestic SCH] DE
LEFT JOIN Business bu ON DE.ContactId = bu.ContactId
LEFT JOIN Design des ON DE.ContactId = des.ContactId
LEFT JOIN Health he ON DE.ContactId = he.ContactId
LEFT JOIN Hospo ho ON DE.ContactId = ho.ContactId
1条答案
按热度按时间dffbzjpn1#
首先编写select语句以获取要删除的所有记录。运行它并确保它工作正常。
然后使上面的select语句只选择要删除的记录的id。例如:
然后在delete语句中,将上面的select语句放在where子句中:
如果您不能完全弄清楚,请发布select语句,该语句返回要删除的记录。