'SQL query error 'Subquery returned more than 1 value...' for DELETE FROM IN

Query:

DELETE FROM [dbo].[Time] 
WHERE UserId IN (SELECT Id FROM [dbo].[Users] WHERE Name like 'test')

sql error:

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

Others advise to use IN instead of = but query already uses IN

This happens if [dbo].[Time] have 2 and more rows with the same UserId

Query looks legit, maybe someone knows what can the problem?

sql


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source