PrestoDB - 按 WHERE IN 子句中指定的顺序对结果进行排序
PrestoDB - Order results by the order specified in the WHERE IN clause
我在 MySQL 中看到了其他 posts that we can do this with the FIELD() 函数。我想知道在 presto 中是否有 FIELD() 的等价物。非常感谢。
不要使用 in
。我会推荐 join
和 values
:
select t.*
from t join
(values (1, 'val1'), (2, 'val2'), (3, 'val3')) v(ord, val)
on t.col = v.val
order by v.ord;
我在 MySQL 中看到了其他 posts that we can do this with the FIELD() 函数。我想知道在 presto 中是否有 FIELD() 的等价物。非常感谢。
不要使用 in
。我会推荐 join
和 values
:
select t.*
from t join
(values (1, 'val1'), (2, 'val2'), (3, 'val3')) v(ord, val)
on t.col = v.val
order by v.ord;