1

I'm trying to execute the next:

em.createQuery("SELECT processId FROM (SELECT processId FROM table_name WHERE processName like '%abcaccz%')")

But I'm getting:

Method threw 'java.lang.IllegalArgumentException' exception.
unexpected token: ( near line 1, column 23

What is missing here? (This is working in my db client area).

2
  • Try adding an alias after the closing paren. Commented May 19, 2019 at 13:09
  • Example, please? Anyway, also this fails: em.createQuery("SELECT processId FROM (SELECT processId FROM table_name WHERE processName like '%abcaccz%') a") Commented May 19, 2019 at 13:09

1 Answer 1

1

The correct syntax is:

em.createQuery("SELECT processId = (SELECT processId FROM table_name WHERE processName like '%abcaccz%') FROM table_name")

or:

em.createQuery("
  SELECT processId
    FROM table_name
    WHERE processId IN (SELECT processId
                           FROM table_name
                           WHERE processName like '%abcaccz%')")
Sign up to request clarification or add additional context in comments.

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.