subquery error

Last post 10-03-2008 3:04 PM by Kobojunkie. 3 replies.
Page 1 of 1 (4 items)
Active Topics My Discussions Unanswered Sort Posts: Previous Next
  • 09-12-2008 10:13 AM

    subquery error

     

    I created a sub query and executed..but it's not throwing up an error.

    table1: col1,col2,col3

    table2 : r1,r2,r3

     table 1 and table 2 column names are completely different.

    I created  a query like

    Select col1 from table1 where col1 not in (select col1 from table2) group by col1.

    We know that col1 is not in the table2.but the output in coming just the name col1.it’s now throwing up and error like “col1 is invalid in table2”

    I am so confused…any help will be appreciated

  • 09-12-2008 2:44 PM In reply to

    Re: subquery error

    For a problem like this, you need to privide the exact text of the query.
    Taking a initial stab in the dark, it sounds like you may have written the original subquery like:
    select 'col1' from table2
    TommCatt
    In theory, there is no difference between theory and practice. In practice, there is.
  • 09-13-2008 4:48 PM In reply to

    Re: subquery error

    If your table2 table does not have a col1 column, then your subquery is simply wrong. Why are you surprised that you get an error for that?

    In general, always provide full table names (including owner) with aliases in the FROM clause of your query, and qualify each and every reference to any column with the appropriate alias.

  • 10-03-2008 3:04 PM In reply to

    Re: subquery error

    Try this

     

    SELECT

    col1

    FROM

    table1 a

    Where

    a.col1 Not in(Select b.col1 from table2)

    group by a.col1

Page 1 of 1 (4 items)
Active Topics   My Discussions    Unanswered Posts


© 2000 - 2007 vDerivatives Limited All Rights Reserved.