以下查询有效,但是MySQL对结果集进行排序:
SELECT STRINGTEXT FROM WEBSTRINGS WHERE GUI=0 AND LANGID='GB' AND TOKENID IN
(312,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62, 63,87,88,89,90,208,210,249,309,310,311);
这意味着,当我在记录集中获取此内容时,
TOKENID 312
的数据为最后而不是第一个,例如
我希望我的结果集可以按以下请求顺序返回:
312,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,6 3,87,88,89,90,208,210,249,309,310,311
但它返回为:
47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,87 ,88,89,90,208,210,249,309,310,311,312
反正有没有让MySQL不对此查询执行此操作?我真的需要
他们照原样回来。
最佳答案
尝试使用'ORDER BY FIELD`
SELECT STRINGTEXT
FROM WEBSTRINGS
WHERE GUI=0 AND LANGID='GB' AND TOKENID IN (312,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62, 63,87,88,89,90,208,210,249,309,310,311)
ORDER BY FIELD (TOKENID,312,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,6 3,87,88,89,90,208,210,249,309,310,311)