0

I don't understand what is wrong with this query. It is giving me a compile time error of "command not ended properly".

The inner query is giving me four records.

select WGN3EVENTPARTICIPANT.EVENTUID 
from 
    (Select WGN_V_ADDRESS_1.ADDRESSUID1 as add1,
            WGN_V_ADDRESS_1.ADDRESSUID2 as add2 
     from WGN3USER inner join 
          WGN_V_ADDRESS_1 on WGN_V_ADDRESS_1.USERID=wgn3user.USERID 
      where WGN3USER.USERNAME='FIRMWIDE\khuraj'
    ) as ta
    ,WGN3EVENTPARTICIPANT 
 where (ta.ADDRESSUID1=WGN3EVENTPARTICIPANT.ADDRESSUID1) AND    
       (ta.ADDRESSUID2=WGN3EVENTPARTICIPANT.ADDRESSUID2)

I am running it in Oracle.

4 Answers 4

1

As others have noted, your original code sample contains several bugs. However the one which causes the specific error you're reporting (ORA-00933) is this.

In Oracle AS is only used for column aliases. So you need to alias your inline view like this:

... where WGN3USER.USERNAME='FIRMWIDE\khuraj'
    )  ta
Sign up to request clarification or add additional context in comments.

Comments

1

You should change where clause to use fields alias:

 where (ta.add1=WGN3EVENTPARTICIPANT.ADDRESSUID1) AND    
       (ta.add2=WGN3EVENTPARTICIPANT.ADDRESSUID2)

EDITED

Try to remove as reserved word in table aliases:

) as ta -> ) ta

Comments

0

'\' is an escape character which needs to be escaped:

Change 'FIRMWIDE\khuraj' in 'FIRMWIDE\\khuraj'

And the outer where-clause references the wrong aliases: ta.ADDRESSUID1 instead of ta.add1 and ta.ADDRESSUID2 instead of ta.add2

1 Comment

but OP says that subquery runs ok ... ?
0
select WGN3EVENTPARTICIPANT.EVENTUID 
from 
    (Select WGN_V_ADDRESS_1.ADDRESSUID1 as add1,
            WGN_V_ADDRESS_1.ADDRESSUID2 as add2 
     from WGN3USER inner join 
          WGN_V_ADDRESS_1 on WGN_V_ADDRESS_1.USERID=wgn3user.USERID 
      where WGN3USER.USERNAME='FIRMWIDE\khuraj'
    ) as ta
    left outer join WGN3EVENTPARTICIPANT on 
 ta.ADDRESSUID1=WGN3EVENTPARTICIPANT.ADDRESSUID1 AND
       ta.ADDRESSUID2=WGN3EVENTPARTICIPANT.ADDRESSUID2

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.