Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2014
    Posts
    2

    Answered: SELECT records from table based on keys - error

    I am using the following select statement to gather records from a related table and I get this error - not sure how to fix after searching around - help please? Many thanks!


    SELECT * FROM revenue_line_items_cstm where (SELECT * from revenue_line_items where name = 'VENUE' AND OPPORTUNITY_ID IS NULL AND id = id_c)

    An unexpected token "END-OF-STATEMENT" was found following "NULL AND id = id_c)". Expected tokens may include: "<interval_qualifier>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.18.60

  2. Best Answer
    Posted by ARWinner

    "Your syntax is incorrect. A where clause has to evaluate to either True or False. A select statement does not do that. You need either EXISTS or IN.

    Andy"


  3. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Your syntax is incorrect. A where clause has to evaluate to either True or False. A select statement does not do that. You need either EXISTS or IN.

    Andy
    Last edited by ARWinner; 02-27-15 at 13:19.

  4. #3
    Join Date
    Oct 2014
    Posts
    2

    Thumbs up Aha - EXISTS works!

    Thank you ARWinner!

    This worked:
    SELECT * FROM REVENUE_LINE_ITEMS_CSTM WHERE EXISTS (SELECT * FROM REVENUE_LINE_ITEMS WHERE NAME ='VENUE' AND OPPORTUNITY_ID IS NULL AND ID = ID_C)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •