这是我的MySQL查询。如何在Oracle中运行此查询?现在它不起作用。
SELECT * FROM mytable WHERE id IN (1,2,3,4) ORDER BY FIELD(id,3,2,1,4);
答案 0 :(得分:2)
这是一个愚蠢的解决方案:(:- D)
SELECT * FROM mytable WHERE id IN (1,2,3,4)
ORDER BY CASE id WHEN 3 THEN 1
WHEN 2 THEN 2
WHEN 1 THEN 3
WHEN 4 THEN 4 END;
或使用DECODE
功能:
SELECT * FROM mytable WHERE id IN (1,2,3,4)
ORDER BY DECODE(id, 3, 1, 2, 2, 1, 3, 4, 4, 0)
答案 1 :(得分:0)
Oracle没有<dom-module id="foo-element">
<template>
<span> Foo element </span>
</template>
</dom-module>
<script>
// if `no-auto-register` is set on the element,
// do not use `HTMLImports.whenReady()` and use
// `addEventListener` to register when an event
// with the value of `register-on-event` property fires.
</script>
功能,但您可以创建自己的功能
FIELD
查询
create TYPE T_VAR IS TABLE OF varchar2(4000);
/
create or replace function FIELD(p_val varchar2, p_var t_var) return number is
begin
for i in 1..p_var.count
loop
if p_val = p_var(i) then
return i;
end if;
end loop;
return p_var.count + 1;
end FIELD;
/
注意:您应该使用此签名SELECT t.*
FROM mytable t
WHERE id IN (1, 2, 3, 4)
order by FIELD(id,T_VAR(3,2,1,4))
再创建一个函数FIELD
,以进行显式数据类型对话。之前的功能是普遍的,但可能会造成一些奇怪的影响。