我的SQL查詢如何使用子查詢其返回不止一個結果
UPDATE Task SET Done = 1 WHERE (ID = (SELECT ID FROM User WHERE UserName = @UserName)
我嘗試和得到了一個錯誤:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been terminated.
是否有任何可能的方式是(例如用於做循環)?謝謝
你有一個以上的用戶名同名?這聽起來很奇怪。也許你忘記傳遞參數,並且你有空白用戶名? (這仍然很奇怪?)。 – gbianchi
@gbianchi - 您在一個允許重複的用戶名的網站上發佈該評論,所以它實際上並不奇怪作爲一個概念。 – JNK
對不起這個不好的例子 – Xitrum