我有一個SQL選擇,我不知道如何實現這一點。我正在檢查兩個字段,看看這些字段是否在列表中。所以像,兩個字段的條件
Select * from MyTable where col1 or col2 in (select col3 from OtherTable where ID=1)
我試圖
Select * from MyTable where
col1 in (select col3 from OtherTable where ID=1)
or col2 in (select col3 from OtherTable where ID=1)
但是,這將返回匹配某些原因第一個條件(只返回COL1,但不是COL2)的記錄。
col2和col3具有相同的數據類型? – Silagy 2011-02-14 15:23:23