我有如下表IN子句並不在我的嵌入式SQL語句作品
Table User
UserID Name
1 Om
2 John
3 Kisan
4 Lisa
5 Karel
Table Game
Games Players
Golf 1,3,5
Football 4
我寫查詢:
Select UserId,
Name from User
Where UserID IN
(Select Players from Game where Games='Golf')
Result:
~~~~~~~
0 Rows
上面的查詢不返回我的任何結果,而它工作得很好,當我在語句中直接指定In子句的值。
Select UserId, Name
from User
Where UserID IN (1,3,5)
Result:
~~~~~~~
UserID Name
1 Om
3 Kisan
5 Karel
3 rows
但是當我改變的條件非常一日查詢與足球:
Select UserId, Name
from User
Where UserID IN
(Select Players
from Game
where Games='Football').
這將返回我以下結果:
UserID Name
4 Lisa
1 row
如何我可以解決,使我非常一號查詢返回我正確的結果?
我覺得我在錯誤的方向。幫幫我!
只是確保...你有兩種資本化。 'UserId'與'UserID'。這是問題嗎? – BlackVegetable
對不起。這確實是Typo錯誤。感謝支持格式化我的問題。 – user2867958