一般來說SQL用 in 的話順序會被打亂
ex :
select prodno,cname,sprice,brand name
from productview
where prodno in ('567105010062','503903020005','510505040001')
出來是
如果要照順序來....有個方法
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,')
全站熱搜
留言列表