谁可以帮我做以下查询工作......
两个表都有字段month,year和userId。我希望删除两个表中的行,以获得月和年的完全相同的值。
从表1,表2中删除 Table1.month NOT IN(1,2) AND Table1.year NOT IN(1,2) AND Table1.userId = 1 AND Table2.userId = Table1.userId
感谢。
答案 0 :(得分:4)
DELETE FROM Table1, Table2
USING Table1, Table2
WHERE Table1.month NOT IN (1,2)
AND Table1.year NOT IN (1, 2)
AND Table1.userId = 1
AND Table2.userId = Table1.userId