Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个来自 Lucene 搜索引擎的 ID 列表,并希望以特定顺序(分数)从数据库中选择这些 ID。
我可以在 SQL 查询中这样做吗?似乎 h2 不知道 ORDER BY FIELD(id, <list,of,ids>) 函数 - 未找到函数“FIELD”。
谢谢你。
SELECT * FROM table WHERE id IN (3,1,2,4) ORDER BY FIELD(id, 3,1,2,4);
这是你需要的吗?
SELECT * FROM table WHERE id IN (3,1,2,4) ORDER BY decode(id,3,1,1,2,2,3,4,4,5);