0

This is my user_agreements table:

|user_id|agreement_id|permitted | |-------|------------|-----------------------| |114983 |1 |2022-07-14 11:52:37.763| |114983 |2 |2022-07-14 12:18:42.100| |114999 |1 |2022-07-14 12:18:52.397| |115011 |1 |2022-07-18 22:39:22.360| |115011 |2 |2022-07-18 22:39:22.717| 

I want to delete this rows:

|user_id|agreement_id|permitted | |-------|------------|-----------------------| |115011 |1 |2022-07-18 22:39:22.360| |115011 |2 |2022-07-18 22:39:22.717| 

Tried with this:

DELETE FROM user_agreements WHERE (user_id, agreement_id) IN ((115011, 1), (115011, 2)) 

But I am getting an error:

SQL Error [4145] [S0001]: An expression of non-boolean type specified in a context where a condition is expected, near ','. 

Any ideas whats wrong there?

5
  • 2
    Tag your dbms name please Commented Jul 20, 2022 at 12:46
  • What's your database? Commented Jul 20, 2022 at 12:47
  • @TheImpaler sql server Commented Jul 20, 2022 at 12:48
  • You can't use IN with multiple columns. That's simply not valid SQL syntax. You can use a table value constructor to create a "table" in the query itself and join with it Commented Jul 20, 2022 at 12:49
  • 1
    As far as I remember SQL Server does not implement IN with tuples in any form (equality, inequality, joins, subqueries, or literals). Oracle, DB2, PostgreSQL, MySQL, MariaDB do... just fyi. Commented Jul 20, 2022 at 12:57

1 Answer 1

3

try this way

DELETE FROM user_agreements WHERE user_id = 115011 and agreement_id IN (1,2)

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.