0

I have the following query for my oracle database that consists of two seperate queries :

ResultSet rs2 = st2.executeQuery("select * from user_col_comments where  substr(table_name,1,3) !="+ "'TCT' and substr(table_name,1,4) != 'ARTZ' and (table in user_tables where secondary='N') ");

This compiles ok within my Java jdbc code. But when I run it, I get the following error:

 java.sql.SQLSyntaxErrorException: ORA-00936: missing expression

I'm aware that the second part of this query doesn't work:

(table in user_tables where secondary='N')

I don't understand why it doesn't work as I'm a complete newbie. And I don't know how to do it right. I checked this here. But I don't think it gives me what I want. I would like to combine these two queries, so that I get all user_col_comments whose table is within user_tables

armel
  • 299
  • 3
  • 14

1 Answers1

1

That should be a subquery, e.g.

and table in (select table_name from user_tables where secondary='N')
Littlefoot
  • 131,892
  • 15
  • 35
  • 57
  • l needed to replace the "table" in your answer with "table_name". And that solved my problem :)thx – armel Dec 16 '20 at 08:45