select * from product where sku in ('119-041','120-051','114-017','101-085','244-079','114-015','238-003','251-012','251-037','243-028','231-364','240-029')
查询出来的产品记录是按照索引顺序排列的,可是我想产品的顺序按照后面的括号里的sku顺序显示,不知道大家有什么方法吗? 没有简便的方法吧,只能写个split的存储过程, 循环拼sql语句, 拼成如下格式: select * from product where sku='119-041' union all select * from product where sku='120-051' .... 最后 exec ('....') 不太明白呢 大家给出出主意啊!谢谢啊 SQL code: select * from product where sku in ('119-041','120-051','114-017','101-085','244-079','114-015','238-003','251-012','251-037','243-028','231-364','240-029') order by charindex(','+ltrim(product)+',',',119-041,120-051,114-017,101-085....,')