先看執行的sql
==> Preparing: SELECT Description,Description_C,SpecialNum from specialnum WHERE SpecialNum in ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) order by field(SpecialNum, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? );
==> Parameters: EG(String), EL(String), EQ(String), EP(String), EO(String), EC(String), EH(String), EW(String), EM(String), EA(String), EI(String), ET(String), EU(String), ED(String), EE(String), EK(String), EF(String), ER(String), E-(String), EB(String), EV(String), EZ(String), EN(String), ES(String), EJ(String), EX(String), EY(String), EG(String), EL(String), EQ(String), EP(String), EO(String), EC(String), EH(String), EW(String), EM(String), EA(String), EI(String), ET(String), EU(String), ED(String), EE(String), EK(String), EF(String), ER(String), E-(String), EB(String), EV(String), EZ(String), EN(String), ES(String), EJ(String), EX(String), EY(String)
<== Columns: Description, Description_C, SpecialNum
<== Row: Multidisciplinary, 多學科, E-
<== Row: Agricultural and Biological Sciences, 農業和生物科學, EA
<== Row: Arts and Humanities, 藝術與人文, EB
<== Row: Biochemistry, Genetics and Molecular Biology, 生物化學,遺傳學和分子生物學, EC
<== Row: Business, Management and Accounting, 商業,管理和會計, ED
<== Row: Chemical Engineering, 化學工程, EE
<== Row: Chemistry, 化學, EF
<== Row: Computer Science, 計算機科學, EG
<== Row: Decision Sciences, 決策科學, EH
<== Row: Earth and Planetary Sciences, 地球與行星科學, EI
<== Row: Economics, Econometrics and Finance, 經濟學,計量經濟學和金融學, EJ
<== Row: Energy, 能源, EK
<== Row: Engineering, 工程, EL
<== Row: Environmental Science, 環境科學, EM
<== Row: Immunology and Microbiology, 免疫學和微生物學, EN
<== Row: Materials Science, 材料科學, EO
<== Row: Mathematics, 數學, EP
<== Row: Medicine, 醫學, EQ
<== Row: Neuroscience, 神經科學, ER
<== Row: Nursing, 看護, ES
<== Row: Pharmacology, Toxicology and Pharmaceutics, 藥理學,毒理學和藥劑學, ET
<== Row: Physics and Astronomy, 物理與天文學, EU
<== Row: Psychology, 心理學, EV
<== Row: Social Sciences, 社會科學, EW
<== Row: Veterinary, 獸醫, EX
<== Row: Dentistry, 牙科, EY
<== Row: Health Professions, 衛生專業, EZ
<== Total: 27
再看xml
<select id="selectSpecialNumName" resultType="java.util.LinkedHashMap">
SELECT Description,Description_C,SpecialNum from specialnum WHERE SpecialNum in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
order by field(SpecialNum,<foreach collection="list" index="index" item="item">
#{item}
</foreach>);
</select>
為什么回傳的結果不是Parameters傳入引數的順序?
uj5u.com熱心網友回復:
樓主這問題很奇怪...mybatis回傳集合的順序只跟查詢的sql的結果集合順序一致,你這個問題應該轉換sql的結果集合順序為何不跟入參一致,這個怕是難了(不是不能),排序也得是有規則的.
建議你查詢完資料再排序,這樣怕是最簡單最符合你需求的解決方案了,lambda運算式搞定這些很輕松
uj5u.com熱心網友回復:
應該是你第二個foreach標簽少了屬性separator=","
SELECT Description,Description_C,SpecialNum from specialnum
WHERE SpecialNum in ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )
order by field(SpecialNum, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? );
uj5u.com熱心網友回復:
你不覺得 這個sql有點奇怪嗎? order by field(SpecialNum, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? )引數之前少逗號啊。
uj5u.com熱心網友回復:
就是按你的SpecialNum 排序的啊,你看看:EA,EB,EC……轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/204865.html
標籤:Web 開發
上一篇:網聯V2X測驗解決方案
下一篇:網路故障監測終端
