ORA-00920:无效的关系运算符3

时间:2016-05-16 14:19:22

标签: sql oracle11g

create or replace view test as
select b.npm1,b.nama,b.IPS,a.ket as ket1,b.IPK,a.ket as ket2
from KHS b left join keterangan a on a.nilai = IPS and
left join keterangan a on a.nilai = IPK

请帮帮我,我的代码出错了什么!!

1 个答案:

答案 0 :(得分:2)

首先,你有一个流浪的'和'在你的两个连接之间(可能是错误的来源)。其次,即使您想要两次加入同一个表,也需要对表进行不同的别名。生成的代码应如下所示:

CREATE OR REPLACE view test AS
SELECT 
    b.npm1,
    b.nama,
    b.IPS,
    a1.ket AS ket1,
    b.IPK,
    a2.ket AS ket2
FROM KHS b 
    LEFT JOIN keterangan a1 
        ON a1.nilai = b.IPS 
    LEFT JOIN keterangan a2
        ON a2.nilai = b.IPK