0

Who can help me make the following query work...

Both tables have the fields month, year and userId. And I want to delete rows in both Tables for the exact same values for month and year.

DELETE FROM 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

Thanks.

1 Answer 1

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

http://dev.mysql.com/doc/refman/5.5/en/delete.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.