一般來說SQL用 in 的話順序會被打亂 

ex : 

select prodno,cname,sprice,brand  name 

from productview 

where prodno in ('567105010062','503903020005','510505040001')

出來是

Clipboard02.png  

 

如果要照順序來....有個方法

ex : 

select prodno,cname,sprice,brandname 

From productview 

Where prodno in ('567105010062','503903020005','510505040001')

 order by charindex(','+rtrim(cast(prodno as varchar(12)))+',',',567105010062,503903020005,510505040001,')



Clipboard02.png

 

 

arrow
arrow
    全站熱搜

    小雕 發表在 痞客邦 留言(0) 人氣()