SQL where in 語句順序問題
你的語句有問題應該這樣
select id , name from test where id in('1001','1005','1003');
如果你想按順序的話 這樣就可以
select id , name from test where id='1001'
union all
select id , name from test where id='1005'
union all
select id , name from test where id='1003'
sql 語句 where
【where 。。in 。。 】 使用【where 。. exists。.】
【where 。。not in 。。 】 使用【where 。. not exists。.】
SELECT [字段1],[字段2],[字段3],。. FROM 表名1 AS a WHERE exists
(SELECT 1 FROM 表名2 AS b WHERE a.[字段X] = b.[字段X] )
注:1、a.[字段X] 和 b.[字段X] 是相互關聯的字段。
2、SELECT 1 FROM 中數字1 是沒有具體含義的你可以使用任何字段,
這里是為了減少占用系統資源建議你使用1。
轉載請注明出處華閱文章網 » whereinsql語句